diff --git a/test/smoke/package.json b/test/smoke/package.json index 6aedcc86f93..6237dc93093 100644 --- a/test/smoke/package.json +++ b/test/smoke/package.json @@ -12,11 +12,13 @@ "@types/htmlparser2": "^3.7.29", "@types/mkdirp": "^0.5.1", "@types/mocha": "^2.2.41", + "@types/ncp": "^2.0.1", "@types/node": "^8.0.26", "@types/rimraf": "^0.0.28", "@types/webdriverio": "^4.6.1", "htmlparser2": "^3.9.2", "mocha": "^3.2.0", + "ncp": "^2.0.0", "rimraf": "^2.6.1", "spectron": "~3.6.4", "strip-json-comments": "^2.0.1", diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 41d9c8c1a16..70ee3158bd2 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -11,9 +11,10 @@ import * as minimist from 'minimist'; import * as tmp from 'tmp'; import * as rimraf from 'rimraf'; import * as mkdirp from 'mkdirp'; +import { ncp } from 'ncp'; const [, , ...args] = process.argv; -const opts = minimist(args, { string: ['build', 'stable-build', 'screenshot'] }); +const opts = minimist(args, { string: ['build', 'stable-build'], boolean: ['screenshot'] }); const tmpDir = tmp.dirSync() as { name: string; removeCallback: Function; }; const testDataPath = tmpDir.name; @@ -76,11 +77,11 @@ if (!fs.existsSync(testCodePath)) { process.env.VSCODE_USER_DIR = path.join(testDataPath, 'user-dir'); process.env.VSCODE_EXTENSIONS_DIR = extensionsPath; -process.env.SCREENSHOTS_DIR = path.join(testDataPath, 'screenshots-dir'); +process.env.SCREENSHOTS_DIR = path.join(testDataPath, 'screenshots'); process.env.SMOKETEST_REPO = testRepoLocalDir; process.env.VSCODE_WORKSPACE_PATH = workspacePath; process.env.VSCODE_KEYBINDINGS_PATH = keybindingsPath; -process.env.CAPTURE_SCREENSHOT = Object.keys(opts).indexOf('screenshot') !== -1 ? 'screenshot' : ''; +process.env.CAPTURE_SCREENSHOT = opts.screenshot ? '1' : ''; if (process.env.VSCODE_DEV === '1') { process.env.VSCODE_EDITION = 'dev'; @@ -106,7 +107,7 @@ function toUri(path: string): string { return `file://${path}`; } -async function main(): Promise { +async function setup(): Promise { console.log('*** Test data:', testDataPath); console.log('*** Preparing smoketest setup...'); @@ -176,9 +177,22 @@ console.warn = function suppressWebdriverWarnings(message) { before(async function () { // allow two minutes for setup this.timeout(2 * 60 * 1000); - await main(); + await setup(); }); +async function teardown(): Promise { + const screenshotsSourcePath = process.env.SCREENSHOTS_DIR; + + if (process.env.CAPTURE_SCREENSHOT && screenshotsSourcePath) { + const screenshotsDestinationPath = path.join(repoPath, '..', 'smoketest-screenshots'); + + rimraf.sync(screenshotsDestinationPath); + await new Promise((c, e) => ncp(screenshotsSourcePath, screenshotsDestinationPath, err => err ? e(err) : c())); + } +} + +after(teardown); + // import './areas/workbench/data-migration.test'; import './areas/workbench/data-loss.test'; import './areas/explorer/explorer.test';