diff --git a/build/tfs/darwin/smoketest.sh b/build/tfs/darwin/smoketest.sh index ad1606c3aad..e666fdec69e 100755 --- a/build/tfs/darwin/smoketest.sh +++ b/build/tfs/darwin/smoketest.sh @@ -24,5 +24,5 @@ step "Build minified & upload source maps" \ step "Run smoke test" \ pushd test/smoke npm install - npm test -- --latest "$AGENT_BUILDDIRECTORY/VSCode-darwin/Visual Studio Code - Insiders.app/Contents/MacOS/Electron" + npm run smoketest -- "$AGENT_BUILDDIRECTORY/VSCode-darwin/Visual Studio Code - Insiders.app/Contents/MacOS/Electron" popd \ No newline at end of file diff --git a/build/tfs/linux/smoketest.sh b/build/tfs/linux/smoketest.sh index 8d71fff1275..e5d34e9e7f4 100644 --- a/build/tfs/linux/smoketest.sh +++ b/build/tfs/linux/smoketest.sh @@ -36,7 +36,7 @@ function configureEnvironment { function runTest { pushd test/smoke npm install - sudo -u testuser -H xvfb-run -a -s "-screen 0 1024x768x8" npm test -- --latest "$AGENT_BUILDDIRECTORY/VSCode-linux-ia32/code-insiders" + sudo -u testuser -H xvfb-run -a -s "-screen 0 1024x768x8" npm run smoketest -- "$AGENT_BUILDDIRECTORY/VSCode-linux-ia32/code-insiders" popd } diff --git a/build/tfs/win32/smoketest.ps1 b/build/tfs/win32/smoketest.ps1 index 2a6519aaaf4..f5d25867103 100644 --- a/build/tfs/win32/smoketest.ps1 +++ b/build/tfs/win32/smoketest.ps1 @@ -40,7 +40,7 @@ step "Build minified" { step "Run smoke test" { exec { & Push-Location test\smoke } exec { & npm install } - exec { & npm test -- --latest "$env:AGENT_BUILDDIRECTORY\VSCode-win32-$global:arch\Code - Insiders.exe" } + exec { & npm run smoketest -- "$env:AGENT_BUILDDIRECTORY\VSCode-win32-$global:arch\Code - Insiders.exe" } exec { & Pop-Location } } diff --git a/test/smoke/README.md b/test/smoke/README.md index 02717c281fb..a22a039e95e 100644 --- a/test/smoke/README.md +++ b/test/smoke/README.md @@ -1,9 +1,14 @@ # VS Code Smoke Testing -- Run `npm install` -- Start the tests: `npm test -- --latest "path/to/binary"`. +``` +npm rum smoketest -- "path/to/code" +``` -If you want to include 'Data Migration' area tests use `npm test -- --latest path/to/binary --stable path/to/currentStable` respectively. +If you want to include 'Data Migration' area tests use: + +``` +npm run smoketest -- "path/to/code" "path/to/codeStable" +``` Detailed prerequisites and running steps are described [in our smoke test wiki](https://github.com/Microsoft/vscode/wiki/Smoke-Test#automated-smoke-test). @@ -50,15 +55,7 @@ To add new test, `./test/${area}.ts` should be updated. The same instruction-sty Almost on every automated test action it captures a screenshot. These help to determine an issue, if smoke test fails. The normal workflow is that you understand what code is doing and then try to match it up with screenshots obtained from the test. # Running "Out of Sources" -If you did a fix in VS Code that you need in order for the smoke test to succeed, here is how you can run the smoke test against the sources of VS Code: -* Set related environment variables in the console: - * `export NODE_ENV=development` - * `export VSCODE_DEV=1` - * `export VSCODE_CLI=1` -* open `application.ts` - * pass in the vscode folder as argument to the application - * e.g. instead of `args: args` type `args: ['/Users/bpasero/Development/vscode', ...args]` -* `cd test/smoke` -* `npm install` -* `npm test -- --latest ` - * e.g. on macOS: `npm test -- --latest /.build/electron/Code\ -\ OSS.app/Contents/MacOS/Electron` \ No newline at end of file + +``` +npm run smoketest +``` \ No newline at end of file diff --git a/test/smoke/package.json b/test/smoke/package.json index 1c3b3a11350..d8bc57d6bc1 100644 --- a/test/smoke/package.json +++ b/test/smoke/package.json @@ -7,7 +7,6 @@ "watch": "tsc --watch" }, "devDependencies": { - "@types/commander": "^2.9.2", "@types/electron": "~1.4.37", "@types/htmlparser2": "^3.7.29", "@types/mkdirp": "^0.5.1", @@ -15,7 +14,6 @@ "@types/node": "^8.0.26", "@types/rimraf": "^0.0.28", "@types/webdriverio": "^4.6.1", - "commander": "^2.9.0", "htmlparser2": "^3.9.2", "mocha": "^3.2.0", "rimraf": "^2.6.1", diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index aee39662243..2f0c4f47900 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -5,56 +5,28 @@ import * as fs from 'fs'; import * as https from 'https'; -// import * as program from 'commander'; import * as cp from 'child_process'; import * as path from 'path'; import * as mkdirp from 'mkdirp'; const testDataPath = path.join(__dirname, '..', 'test_data'); -const codeWorkspacePath = path.join(testDataPath, 'smoketest.code-workspace'); +const workspacePath = path.join(testDataPath, 'smoketest.code-workspace'); const testRepoUrl = 'https://github.com/Microsoft/vscode-smoketest-express'; const testRepoLocalDir = path.join(testDataPath, 'vscode-smoketest-express'); - mkdirp.sync(testDataPath); -// program -// .option('-l, --latest ', 'path to the latest VS Code to test') -// .option('-s, --stable [file path]', 'path to the stable VS Code to be used in data migration tests'); - -// program.on('--help', () => { -// console.log(' Examples:'); -// console.log(''); -// console.log(' $ npm test -- --latest path/to/binary'); -// console.log(' $ npm test -- -l path/to/binary'); -// console.log(''); -// console.log(' $ npm test -- --latest path/to/latest/binary --stable path/to/stable/binary'); -// console.log(' $ npm test -- -l path/to/latest/binary -s path/to/stable/binary'); -// console.log(''); -// }); - -// program.parse(process.argv); - function fail(errorMessage): void { console.error(errorMessage); process.exit(1); } -// if (!program.latest) { -// fail('You must specify the binary to run the smoke test against'); -// } -// if (!fs.existsSync(program.latest) || (program.stable && !fs.existsSync(program.stable))) { -// fail('The file path to electron binary does not exist or permissions do not allow to execute it. Please check the path provided.'); -// } -// if (parseInt(process.version.substr(1)) < 6) { -// fail('Please update your Node version to greater than 6 to run the smoke test.'); -// } - -// Setting up environment variables - +if (parseInt(process.version.substr(1)) < 6) { + fail('Please update your Node version to greater than 6 to run the smoke test.'); +} const repoPath = path.join(__dirname, '..', '..', '..'); -function getDevElectronPath() { +function getDevElectronPath(): string { const buildPath = path.join(repoPath, '.build'); const product = require(path.join(repoPath, 'product.json')); @@ -65,23 +37,37 @@ function getDevElectronPath() { return path.join(buildPath, 'electron', `${product.applicationName}`); case 'win32': return path.join(buildPath, 'electron', `${product.nameShort}.exe`); + default: + throw new Error('Unsupported platform.'); } } -// TODO@joao: make this change -process.env.VSCODE_PATH = getDevElectronPath(); -process.env.VSCODE_REPOSITORY = repoPath; -process.env.VSCODE_DEV = '1'; -process.env.VSCODE_CLI = '1'; +let [, , testCodePath, stableCodePath] = process.argv; + +if (testCodePath) { + process.env.VSCODE_PATH = testCodePath; + + if (stableCodePath) { + process.env.VSCODE_STABLE_PATH = stableCodePath; + } +} else { + testCodePath = getDevElectronPath(); + process.env.VSCODE_PATH = testCodePath; + process.env.VSCODE_REPOSITORY = repoPath; + process.env.VSCODE_DEV = '1'; + process.env.VSCODE_CLI = '1'; +} + +if (!fs.existsSync(testCodePath)) { + fail(`Can't find Code at ${testCodePath}.`); +} -// if (program.stable) { -// process.env.VSCODE_STABLE_PATH = program.stable; -// } process.env.SMOKETEST_REPO = testRepoLocalDir; -// if (program.latest && (program.latest.indexOf('Code - Insiders') /* macOS/Windows */ || program.latest.indexOf('code-insiders') /* Linux */) >= 0) { -// process.env.VSCODE_EDITION = 'insiders'; -// } -process.env.VSCODE_WORKSPACE_PATH = codeWorkspacePath; +process.env.VSCODE_WORKSPACE_PATH = workspacePath; + +if ((testCodePath.indexOf('Code - Insiders') /* macOS/Windows */ || testCodePath.indexOf('code-insiders') /* Linux */) >= 0) { + process.env.VSCODE_EDITION = 'insiders'; +} function getKeybindingPlatform(): string { switch (process.platform) { @@ -113,7 +99,7 @@ async function main(): Promise { }).on('error', e); }); - if (!fs.existsSync(codeWorkspacePath)) { + if (!fs.existsSync(workspacePath)) { console.log('Creating workspace file...'); const workspace = { id: (Date.now() + Math.round(Math.random() * 1000)).toString(), @@ -124,7 +110,7 @@ async function main(): Promise { ] }; - fs.writeFileSync(codeWorkspacePath, JSON.stringify(workspace, null, '\t')); + fs.writeFileSync(workspacePath, JSON.stringify(workspace, null, '\t')); } if (!fs.existsSync(testRepoLocalDir)) {