diff --git a/.github/workflows/insiders.yml b/.github/workflows/insiders.yml index 0c22f7b44..f302f0e01 100644 --- a/.github/workflows/insiders.yml +++ b/.github/workflows/insiders.yml @@ -47,4 +47,4 @@ jobs: if: failure() with: name: screenshots-${{ matrix.os }} - path: ${{ github.workspace }}/test/**/screenshots/*.png + path: ${{ runner.temp }}/test-resources/screenshots/*.png diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1e02848b1..896772998 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,18 +37,22 @@ jobs: if: matrix.os != 'ubuntu-latest' run: | npm run test + echo ${{ runner.temp }} - name: Run Tests (linux) if: matrix.os == 'ubuntu-latest' run: | xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run test + echo ${{ runner.temp }} - name: Upload Screenshots + env: + TEST_RESOURCES: testik uses: actions/upload-artifact@v3 if: failure() with: name: screenshots-${{ matrix.os }}-${{ matrix.version }} - path: ${{ github.workspace }}/test/**/screenshots/*.png + path: ${{ runner.temp }}/**/screenshots/*.png check: if: always() diff --git a/.gitignore b/.gitignore index 243307177..8d7358218 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ out node_modules -test-resources ./.vscode docs resources/api-handler.vsix diff --git a/src/browser.ts b/src/browser.ts index c2056c95d..1b6581205 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -7,6 +7,7 @@ import { WebDriver, Builder, until, initPageObjects, logging, By } from 'monaco- import { Options, ServiceBuilder } from 'selenium-webdriver/chrome'; import { getLocatorsPath } from 'vscode-extension-tester-locators'; import { CodeUtil, ReleaseQuality } from './util/codeUtil'; +import { DEFAULT_STORAGE_FOLDER } from './extester'; export class VSBrowser { static readonly baseVersion = '1.37.0'; @@ -21,7 +22,7 @@ export class VSBrowser { private static _instance: VSBrowser; constructor(codeVersion: string, releaseType: ReleaseQuality, customSettings: Object = {}, logLevel: logging.Level = logging.Level.INFO) { - this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve('test-resources'); + this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve(DEFAULT_STORAGE_FOLDER); this.extensionsFolder = process.env.EXTENSIONS_FOLDER ? process.env.EXTENSIONS_FOLDER : undefined; this.customSettings = customSettings; this.codeVersion = codeVersion; diff --git a/src/extester.ts b/src/extester.ts index 593787f23..3071c145c 100644 --- a/src/extester.ts +++ b/src/extester.ts @@ -4,6 +4,7 @@ import { CodeUtil, DEFAULT_RUN_OPTIONS, ReleaseQuality, RunOptions } from './uti import { DriverUtil } from './util/driverUtil'; import * as fs from 'fs-extra'; import * as path from 'path'; +import * as os from 'os'; import { URL } from 'url'; export { ReleaseQuality } @@ -26,6 +27,8 @@ export const DEFAULT_SETUP_OPTIONS = { installDependencies: false } +export const DEFAULT_STORAGE_FOLDER = path.join(os.tmpdir(), 'test-resources'); + export const VSCODE_VERSION_MIN = '1.81.1'; export const VSCODE_VERSION_MAX = '1.83.1'; @@ -42,10 +45,15 @@ export class ExTester { private code: CodeUtil; private chrome: DriverUtil; - constructor(storageFolder: string = 'test-resources', releaseType: ReleaseQuality = ReleaseQuality.Stable, extensionsDir?: string) { + constructor(storageFolder: string = DEFAULT_STORAGE_FOLDER, releaseType: ReleaseQuality = ReleaseQuality.Stable, extensionsDir?: string) { this.code = new CodeUtil(storageFolder, releaseType, extensionsDir); this.chrome = new DriverUtil(storageFolder); + console.log(`TMP = ${process.env.TMP}`); + console.log(`TEMP = ${process.env.TEMP}`); + console.log(`TMPDIR = ${process.env.TMPDIR}`); + console.log(`os.tmpDir = ${os.tmpdir()}`); + if (process.versions.node > NODEJS_VERSION_MAX) { console.log('\x1b[31m%s\x1b[0m', ` ERROR: You are using the unsupported NodeJS version '${process.versions.node}'. The latest supported version is '${NODEJS_VERSION_MAX}'. diff --git a/src/util/codeUtil.ts b/src/util/codeUtil.ts index 49a6fb282..83d78c180 100644 --- a/src/util/codeUtil.ts +++ b/src/util/codeUtil.ts @@ -8,6 +8,7 @@ import { VSRunner } from "../suite/runner"; import { Unpack } from "./unpack"; import { logging } from "selenium-webdriver"; import { Download } from './download'; +import { DEFAULT_STORAGE_FOLDER } from '../extester'; export enum ReleaseQuality { Stable = 'stable', @@ -60,7 +61,7 @@ export class CodeUtil { * @param folder Path to folder where all the artifacts will be stored. * @param extensionsFolder Path to use as extensions directory by VSCode */ - constructor(folder: string = 'test-resources', type: ReleaseQuality = ReleaseQuality.Stable, extensionsFolder?: string) { + constructor(folder: string = DEFAULT_STORAGE_FOLDER, type: ReleaseQuality = ReleaseQuality.Stable, extensionsFolder?: string) { this.availableVersions = []; this.downloadPlatform = this.getPlatform(); this.downloadFolder = path.resolve(folder); diff --git a/src/util/driverUtil.ts b/src/util/driverUtil.ts index b6d2ce12c..67873a15b 100644 --- a/src/util/driverUtil.ts +++ b/src/util/driverUtil.ts @@ -5,6 +5,7 @@ import * as path from 'path'; import * as child_process from 'child_process'; import { Unpack } from './unpack'; import { Download } from './download'; +import { DEFAULT_STORAGE_FOLDER } from '../extester'; /** * Handles version checks and download of ChromeDriver @@ -16,7 +17,7 @@ export class DriverUtil { * Create an instance of chrome driver handler * @param folder path to a folder to store all artifacts */ - constructor(folder: string = 'test-resources') { + constructor(folder: string = DEFAULT_STORAGE_FOLDER) { this.downloadFolder = path.resolve(folder); } diff --git a/test/test-project/.gitignore b/test/test-project/.gitignore index 75fdd7836..33777fc9c 100644 --- a/test/test-project/.gitignore +++ b/test/test-project/.gitignore @@ -2,6 +2,5 @@ out node_modules .vscode-test/ *.vsix -test-resources/ test-extensions/ package-lock.json \ No newline at end of file diff --git a/test/test-project/.vscodeignore b/test/test-project/.vscodeignore index 7f118deb9..ec261f15e 100644 --- a/test/test-project/.vscodeignore +++ b/test/test-project/.vscodeignore @@ -1,3 +1,2 @@ src/** -test-resources/** test-extensions/** \ No newline at end of file diff --git a/test/test-project/package.json b/test/test-project/package.json index ebf16c5bf..63508099f 100644 --- a/test/test-project/package.json +++ b/test/test-project/package.json @@ -147,7 +147,7 @@ "lint": "eslint src --ext .ts", "watch": "tsc -watch -p ./", "cb-init": "echo hello_ExTester | clipboard", - "ui-test": "npm run cb-init && extest setup-and-run './out/src/test/cli/order-3-test.js' './out/src/test/cli/order-2-test.js' './out/src/test/cli/order-1-test.js' './out/src/test/**/*-test.js' './out/src/test/system/clipboard.test.js' -u -i -r . -e ./test-extensions" + "ui-test": "npm run cb-init && extest setup-and-run './out/src/test/cli/order-3-test.js' './out/src/test/cli/order-2-test.js' './out/src/test/cli/order-1-test.js' './out/src/test/**/bottomBar*-test.js' './out/src/test/system/clipboard.test.js' -u -i -r . -e ./test-extensions" }, "devDependencies": { "@types/chai": "^4.3.4", diff --git a/test/test-project/src/test/bottomBar/bottomBarPanel-test.ts b/test/test-project/src/test/bottomBar/bottomBarPanel-test.ts index bf12f4a9a..fc9832c91 100644 --- a/test/test-project/src/test/bottomBar/bottomBarPanel-test.ts +++ b/test/test-project/src/test/bottomBar/bottomBarPanel-test.ts @@ -16,7 +16,7 @@ describe('BottomBarPanel', function () { it('can be toggled open', async function () { await panel.toggle(true); - expect(await panel.isDisplayed()).is.true; + expect(await panel.isDisplayed()).is.false; }); it('can be toggled closed', async function () { diff --git a/test/test-project/tsconfig.json b/test/test-project/tsconfig.json index e885fa410..a5d178618 100644 --- a/test/test-project/tsconfig.json +++ b/test/test-project/tsconfig.json @@ -11,5 +11,5 @@ "resolveJsonModule": true, "esModuleInterop": true }, - "exclude": ["node_modules", ".vscode-test", "test-resources", "resources"] + "exclude": ["node_modules", ".vscode-test", "resources"] } diff --git a/test/test-project/tslint.json b/test/test-project/tslint.json index 5283a9bb2..469c59d54 100644 --- a/test/test-project/tslint.json +++ b/test/test-project/tslint.json @@ -8,8 +8,5 @@ "semicolon": [true, "always"], "triple-equals": true }, - "defaultSeverity": "warning", - "linterOptions": { - "exclude": ["test-resources"] - } + "defaultSeverity": "warning" } diff --git a/wiki/Taking Screenshots.md b/wiki/Taking Screenshots.md index 834d80f4f..507dc1981 100644 --- a/wiki/Taking Screenshots.md +++ b/wiki/Taking Screenshots.md @@ -5,7 +5,7 @@ Screenshot can be captured by calling: VSBrowser.instance.takeScreenshot(basename: string) ``` -Captured screenshots will be saved in *screenshots* folder which can be found in *test-resources* folder. +Captured screenshots will be saved in *screenshots* folder which can be found in a test storage folder (`$TMPDIR/test-resources` by default). File name will be generated from given basename in the following format: `${basename}.png`. #### Mocha integration diff --git a/wiki/Test-Setup.md b/wiki/Test-Setup.md index 409bc4198..078310cd5 100644 --- a/wiki/Test-Setup.md +++ b/wiki/Test-Setup.md @@ -1,7 +1,7 @@ The Extension Tester offers both CLI and API to perform all the setup actions. That way you can simply integrate it into your npm scripts, or just call it from your code if that is more preferable. ## Using the CLI -All the CLI actions are available with the command ```extest``` which is available to your npm scripts once the package is installed. The default storage folder for all test resources is ```test-resources``` in the extension's root. To avoid build problems, make sure to exclude it from your ```tsconfig``` and ```vsce```. +All the CLI actions are available with the command ```extest``` which is available to your npm scripts once the package is installed. The default storage folder for all test resources is a ```$TMPDIR/test-resources```. #### Download VS Code If you wish to manually download VS Code of a given version