From 29a8be39f16631c6af137c73f92bfc69b2eaafae Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 5 Jun 2018 15:24:41 +0200 Subject: [PATCH] smoke: save logs as artifacts --- test/smoke/src/application.ts | 1 + test/smoke/src/main.ts | 14 +++++++++++++- test/smoke/src/vscode/code.ts | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/smoke/src/application.ts b/test/smoke/src/application.ts index 4894252466c..7e08c89d140 100644 --- a/test/smoke/src/application.ts +++ b/test/smoke/src/application.ts @@ -106,6 +106,7 @@ export class Application { extensionsPath: this.options.extensionsPath, logger: this.options.logger, verbose: this.options.verbose, + log: this.options.log, extraArgs, }); diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 69caa041d41..8daf48f394c 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -10,6 +10,7 @@ import * as minimist from 'minimist'; import * as tmp from 'tmp'; import * as rimraf from 'rimraf'; import * as mkdirp from 'mkdirp'; +import { ncp } from 'ncp'; import { Application, Quality } from './application'; import { setup as setupDataMigrationTests } from './areas/workbench/data-migration.test'; @@ -210,8 +211,11 @@ function createApp(quality: Quality): Application { loggers.push(new ConsoleLogger()); } + let log: string | undefined = undefined; + if (opts.log) { loggers.push(new FileLogger(opts.log)); + log = 'verbose'; } return new Application({ @@ -223,7 +227,8 @@ function createApp(quality: Quality): Application { workspaceFilePath, waitTime: parseInt(opts['wait-time'] || '0') || 20, logger: new MultiLogger(loggers), - verbose: opts.verbose + verbose: opts.verbose, + log }); } @@ -235,6 +240,13 @@ before(async function () { after(async function () { await new Promise(c => setTimeout(c, 500)); // wait for shutdown + + if (opts.log) { + const logsDir = path.join(userDataDir, 'logs'); + const destLogsDir = path.join(path.dirname(opts.log), 'logs'); + await new Promise((c, e) => ncp(logsDir, destLogsDir, err => err ? e(err) : c())); + } + await new Promise((c, e) => rimraf(testDataPath, { maxBusyTries: 10 }, err => err ? e(err) : c())); }); diff --git a/test/smoke/src/vscode/code.ts b/test/smoke/src/vscode/code.ts index 4162d6419dc..dfe86f351bd 100644 --- a/test/smoke/src/vscode/code.ts +++ b/test/smoke/src/vscode/code.ts @@ -89,6 +89,7 @@ export interface SpawnOptions { logger: Logger; verbose?: boolean; extraArgs?: string[]; + log?: string; } async function createDriverHandle(): Promise { @@ -127,6 +128,10 @@ export async function spawn(options: SpawnOptions): Promise { args.push('--driver-verbose'); } + if (options.log) { + args.push('--log', options.log); + } + if (options.extraArgs) { args.push(...options.extraArgs); }