Skip to content

Commit 7bb6df9

Browse files
authored
Merge pull request microsoft#80293 from jasongin/automation
Refactor smoke UI automation into separate package
2 parents a556ca9 + 36410ba commit 7bb6df9

53 files changed

Lines changed: 2129 additions & 994 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/gulpfile.hygiene.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const indentationFilter = [
5757
'!test/assert.js',
5858

5959
// except specific folders
60+
'!test/automation/out/**',
6061
'!test/smoke/out/**',
6162
'!extensions/vscode-api-tests/testWorkspace/**',
6263
'!extensions/vscode-api-tests/testWorkspace2/**',
@@ -152,6 +153,7 @@ const tslintCoreFilter = [
152153
'src/**/*.ts',
153154
'test/**/*.ts',
154155
'!extensions/**/*.ts',
156+
'!test/automation/**',
155157
'!test/smoke/**',
156158
...tslintBaseFilter
157159
];
@@ -160,6 +162,7 @@ const tslintExtensionsFilter = [
160162
'extensions/**/*.ts',
161163
'!src/**/*.ts',
162164
'!test/**/*.ts',
165+
'test/automation/**/*.ts',
163166
...tslintBaseFilter
164167
];
165168

build/npm/postinstall.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ runtime "${runtime}"`;
7070
}
7171

7272
yarnInstall(`build`); // node modules required for build
73+
yarnInstall('test/automation'); // node modules required for smoketest
7374
yarnInstall('test/smoke'); // node modules required for smoketest
7475
yarnInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron
7576

test/automation/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
npm-debug.log
3+
Thumbs.db
4+
node_modules/
5+
out/
6+
keybindings.*.json
7+
src/driver.d.ts

test/automation/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# VS Code Automation Package
2+
3+
This package contains functionality for automating various components of the VS Code UI, via an automation "driver" that connects from a separate process. It is used by the `smoke` tests.

test/automation/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "vscode-automation",
3+
"version": "1.39.0",
4+
"description": "VS Code UI automation driver",
5+
"author": {
6+
"name": "Microsoft Corporation"
7+
},
8+
"license": "MIT",
9+
"main": "./out/index.js",
10+
"private": true,
11+
"scripts": {
12+
"postinstall": "npm run compile",
13+
"compile": "npm run copy-driver && npm run copy-driver-definition && tsc",
14+
"watch": "concurrently \"npm run watch-driver\" \"npm run watch-driver-definition\" \"tsc --watch\"",
15+
"copy-driver": "cpx src/driver.js out/",
16+
"watch-driver": "cpx src/driver.js out/ -w",
17+
"copy-driver-definition": "node tools/copy-driver-definition.js",
18+
"watch-driver-definition": "watch \"node tools/copy-driver-definition.js\" ../../src/vs/platform/driver/node",
19+
"copy-package-version": "node tools/copy-package-version.js",
20+
"prepublishOnly": "npm run copy-package-version"
21+
},
22+
"devDependencies": {
23+
"@types/mkdirp": "0.5.1",
24+
"@types/ncp": "2.0.1",
25+
"@types/node": "8.0.33",
26+
"@types/puppeteer": "^1.19.0",
27+
"@types/tmp": "0.1.0",
28+
"concurrently": "^3.5.1",
29+
"cpx": "^1.5.0",
30+
"typescript": "2.9.2",
31+
"watch": "^1.0.2"
32+
},
33+
"dependencies": {
34+
"mkdirp": "^0.5.1",
35+
"ncp": "^2.0.0",
36+
"puppeteer": "^1.19.0",
37+
"tmp": "0.1.0",
38+
"vscode-uri": "^2.0.3"
39+
}
40+
}

test/smoke/src/areas/activitybar/activityBar.ts renamed to test/automation/src/activityBar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Code } from '../../vscode/code';
6+
import { Code } from './code';
77

88
export const enum ActivityBarPosition {
99
LEFT = 0,
@@ -27,4 +27,4 @@ export class ActivityBar {
2727

2828
await this.code.waitForElement(`.part.activitybar.${positionClass}`);
2929
}
30-
}
30+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import * as fs from 'fs';
77
import * as path from 'path';
8-
import { Workbench } from './areas/workbench/workbench';
9-
import { Code, spawn, SpawnOptions } from './vscode/code';
8+
import { Workbench } from './workbench';
9+
import { Code, spawn, SpawnOptions } from './code';
1010
import { Logger } from './logger';
1111

1212
export const enum Quality {
@@ -25,7 +25,7 @@ export interface ApplicationOptions extends SpawnOptions {
2525
export class Application {
2626

2727
private _code: Code | undefined;
28-
private _workbench: Workbench;
28+
private _workbench: Workbench | undefined;
2929

3030
constructor(private options: ApplicationOptions) {
3131
this._workspacePathOrFolder = options.workspacePath;
@@ -40,7 +40,7 @@ export class Application {
4040
}
4141

4242
get workbench(): Workbench {
43-
return this._workbench;
43+
return this._workbench!;
4444
}
4545

4646
get logger(): Logger {
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import * as mkdirp from 'mkdirp';
1111
import { tmpName } from 'tmp';
1212
import { IDriver, connect as connectElectronDriver, IDisposable, IElement, Thenable } from './driver';
1313
import { connect as connectPuppeteerDriver, launch } from './puppeteerDriver';
14-
import { Logger } from '../logger';
14+
import { Logger } from './logger';
1515
import { ncp } from 'ncp';
1616
import { URI } from 'vscode-uri';
1717

18-
const repoPath = path.join(__dirname, '../../../..');
18+
const repoPath = path.join(__dirname, '../../..');
1919

2020
function getDevElectronPath(): string {
2121
const buildPath = path.join(repoPath, '.build');
@@ -237,13 +237,14 @@ export class Code {
237237
throw new Error('Invalid usage');
238238
}
239239

240-
if (typeof target[prop] !== 'function') {
241-
return target[prop];
240+
const targetProp = (target as any)[prop];
241+
if (typeof targetProp !== 'function') {
242+
return targetProp;
242243
}
243244

244-
return function (...args) {
245+
return function (this: any, ...args: any[]) {
245246
logger.log(`${prop}`, ...args.filter(a => typeof a === 'string'));
246-
return target[prop].apply(this, args);
247+
return targetProp.apply(this, args);
247248
};
248249
}
249250
});
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Viewlet } from '../workbench/viewlet';
7-
import { Commands } from '../workbench/workbench';
8-
import { Code, findElement } from '../../vscode/code';
9-
import { Editors } from '../editor/editors';
10-
import { Editor } from '../editor/editor';
11-
import { IElement } from '../../vscode/driver';
6+
import { Viewlet } from './viewlet';
7+
import { Commands } from './workbench';
8+
import { Code, findElement } from './code';
9+
import { Editors } from './editors';
10+
import { Editor } from './editor';
11+
import { IElement } from '../src/driver';
1212

1313
const VIEWLET = 'div[id="workbench.view.debug"]';
1414
const DEBUG_VIEW = `${VIEWLET} .debug-view-content`;
@@ -25,7 +25,7 @@ const DEBUG_STATUS_BAR = `.statusbar.debugging`;
2525
const NOT_DEBUG_STATUS_BAR = `.statusbar:not(debugging)`;
2626
const TOOLBAR_HIDDEN = `.debug-toolbar[aria-hidden="true"]`;
2727
const STACK_FRAME = `${VIEWLET} .monaco-list-row .stack-frame`;
28-
const SPECIFIC_STACK_FRAME = filename => `${STACK_FRAME} .file[title*="${filename}"]`;
28+
const SPECIFIC_STACK_FRAME = (filename: string) => `${STACK_FRAME} .file[title*="${filename}"]`;
2929
const VARIABLE = `${VIEWLET} .debug-variables .monaco-list-row .expression`;
3030
const CONSOLE_OUTPUT = `.repl .output.expression .value`;
3131
const CONSOLE_EVALUATION_RESULT = `.repl .evaluation-result.expression .value`;

0 commit comments

Comments
 (0)