提交 4756d8d9 编写于 作者: J Joao Moreno

smoke: log main and renderer processes

上级 3a399200
......@@ -41,7 +41,7 @@ function smoketest {
ARTIFACTS="$AGENT_BUILDDIRECTORY/smoketest-artifacts"
rm -rf $ARTIFACTS
npm run smoketest -- --build "$AGENT_BUILDDIRECTORY/VSCode-darwin/Visual Studio Code - Insiders.app" --debug $ARTIFACTS
npm run smoketest -- --build "$AGENT_BUILDDIRECTORY/VSCode-darwin/Visual Studio Code - Insiders.app" --log $ARTIFACTS
}
step "Run smoke test" \
......
......@@ -49,7 +49,7 @@ function smoketest {
chown -R testuser $ARTIFACTS
ps -o pid= -u testuser | xargs sudo kill -9
DISPLAY=:10 sudo -i -u testuser -- sh -c "cd $BUILD_SOURCESDIRECTORY/test/smoke && ./node_modules/.bin/mocha --build $AGENT_BUILDDIRECTORY/VSCode-linux-$ARCH --debug $ARTIFACTS"
DISPLAY=:10 sudo -i -u testuser -- sh -c "cd $BUILD_SOURCESDIRECTORY/test/smoke && ./node_modules/.bin/mocha --build $AGENT_BUILDDIRECTORY/VSCode-linux-$ARCH --log $ARTIFACTS"
# DISPLAY=:10 sudo -i -u testuser -- sh -c "cd /vso/work/1/s/test/smoke && ./node_modules/.bin/mocha --build /vso/work/1/VSCode-linux-ia32"
}
......
......@@ -56,7 +56,7 @@ step "Run smoke test" {
$Artifacts = "$env:AGENT_BUILDDIRECTORY\smoketest-artifacts"
Remove-Item -Recurse -Force -ErrorAction Ignore $Artifacts
exec { & npm run smoketest -- --build "$env:AGENT_BUILDDIRECTORY\VSCode-win32-$global:arch" --debug "$Artifacts" }
exec { & npm run smoketest -- --build "$env:AGENT_BUILDDIRECTORY\VSCode-win32-$global:arch" --log "$Artifacts" }
}
done
......@@ -51,7 +51,7 @@ step "Run smoke test" {
$Artifacts = "$env:AGENT_BUILDDIRECTORY\smoketest-artifacts"
Remove-Item -Recurse -Force -ErrorAction Ignore $Artifacts
exec { & npm run smoketest -- --build "$env:AGENT_BUILDDIRECTORY\VSCode-win32-$global:arch" --debug "$Artifacts" }
exec { & npm run smoketest -- --build "$env:AGENT_BUILDDIRECTORY\VSCode-win32-$global:arch" --log "$Artifacts" }
}
step "Create archive and setup package" {
......
......@@ -21,12 +21,12 @@ const opts = minimist(args, {
string: [
'build',
'stable-build',
'debug',
'log',
'wait-time'
]
});
process.env.ARTIFACTS_DIR = opts.debug || '';
process.env.ARTIFACTS_DIR = opts.log || '';
const workspacePath = path.join(testDataPath, 'smoketest.code-workspace');
const testRepoUrl = 'https://github.com/Microsoft/vscode-smoketest-express';
......
......@@ -54,12 +54,15 @@ export class SpectronApplication {
private _workbench: Workbench;
private _screenCapturer: ScreenCapturer;
private spectron: Application;
private keybindings: any[];
private keybindings: any[]; private stopLogCollection: (() => Promise<void>) | undefined;
constructor(private _electronPath: string = LATEST_PATH, private _workspace: string = WORKSPACE_PATH, private _userDir: string = USER_DIR) {
}
constructor(
private _electronPath: string = LATEST_PATH,
private _workspace: string = WORKSPACE_PATH,
private _userDir: string = USER_DIR
) { }
public get build(): VSCODE_BUILD {
get build(): VSCODE_BUILD {
switch (VSCODE_EDITION) {
case 'dev':
return VSCODE_BUILD.DEV;
......@@ -69,27 +72,27 @@ export class SpectronApplication {
return VSCODE_BUILD.STABLE;
}
public get app(): Application {
get app(): Application {
return this.spectron;
}
public get client(): SpectronClient {
get client(): SpectronClient {
return this._client;
}
public get webclient(): WebClient {
get webclient(): WebClient {
return this.spectron.client;
}
public get screenCapturer(): ScreenCapturer {
get screenCapturer(): ScreenCapturer {
return this._screenCapturer;
}
public get workbench(): Workbench {
get workbench(): Workbench {
return this._workbench;
}
public async start(testSuiteName: string, codeArgs: string[] = [], env = process.env): Promise<any> {
async start(testSuiteName: string, codeArgs: string[] = [], env = process.env): Promise<any> {
await this.retrieveKeybindings();
cp.execSync('git checkout .', { cwd: WORKSPACE_PATH });
await this.startApplication(testSuiteName, codeArgs, env);
......@@ -98,17 +101,22 @@ export class SpectronApplication {
await this.screenCapturer.capture('Application started');
}
public async reload(): Promise<any> {
async reload(): Promise<any> {
await this.workbench.quickopen.runCommand('Reload Window');
// TODO @sandy: Find a proper condition to wait for reload
await new Promise(c => setTimeout(c, 500));
await this.checkWindowReady();
}
public async stop(): Promise<any> {
async stop(): Promise<any> {
if (this.stopLogCollection) {
await this.stopLogCollection();
this.stopLogCollection = undefined;
}
if (this.spectron && this.spectron.isRunning()) {
await this.screenCapturer.capture('Stopping application');
return await this.spectron.stop();
await this.spectron.stop();
}
}
......@@ -158,10 +166,11 @@ export class SpectronApplication {
requireName: 'nodeRequire'
};
let testsuiteRootPath: string | undefined = undefined;
let screenshotsDirPath: string | undefined = undefined;
if (ARTIFACTS_DIR) {
const testsuiteRootPath = path.join(ARTIFACTS_DIR, sanitize(testSuiteName));
testsuiteRootPath = path.join(ARTIFACTS_DIR, sanitize(testSuiteName));
mkdirp.sync(testsuiteRootPath);
// Collect screenshots
......@@ -181,6 +190,39 @@ export class SpectronApplication {
this.spectron = new Application(opts);
await this.spectron.start();
if (testsuiteRootPath) {
// Collect logs
const mainProcessLogPath = path.join(testsuiteRootPath, 'main.log');
const rendererProcessLogPath = path.join(testsuiteRootPath, 'renderer.log');
const flush = async () => {
const mainLogs = await this.spectron.client.getMainProcessLogs();
await new Promise((c, e) => fs.appendFile(mainProcessLogPath, mainLogs.join('\n'), { encoding: 'utf8' }, err => err ? e(err) : c()));
const rendererLogs = (await this.spectron.client.getRenderProcessLogs()).map(m => `${m.timestamp} - ${m.level} - ${m.message}`);
await new Promise((c, e) => fs.appendFile(rendererProcessLogPath, rendererLogs.join('\n'), { encoding: 'utf8' }, err => err ? e(err) : c()));
};
let running = true;
const loopFlush = async () => {
while (true) {
await flush();
if (!running) {
return;
}
await new Promise(c => setTimeout(c, 1000));
}
};
const loopPromise = loopFlush();
this.stopLogCollection = () => {
running = false;
return loopPromise;
};
}
this._screenCapturer = new ScreenCapturer(this.spectron, screenshotsDirPath);
this._client = new SpectronClient(this.spectron, this);
this._workbench = new Workbench(this);
......@@ -220,7 +262,7 @@ export class SpectronApplication {
* Retrieves the command from keybindings file and executes it with WebdriverIO client API
* @param command command (e.g. 'workbench.action.files.newUntitledFile')
*/
public command(command: string, capture?: boolean): Promise<any> {
command(command: string, capture?: boolean): Promise<any> {
const binding = this.keybindings.find(x => x['command'] === command);
if (!binding) {
return this.workbench.quickopen.runCommand(command);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册