parent
bd55fd8d7b
commit
554eb6e796
4 changed files with 35 additions and 48 deletions
|
@ -16,7 +16,7 @@ export enum Quality {
|
||||||
|
|
||||||
export interface ApplicationOptions extends SpawnOptions {
|
export interface ApplicationOptions extends SpawnOptions {
|
||||||
quality: Quality;
|
quality: Quality;
|
||||||
folderPath: string;
|
workspacePath: string;
|
||||||
workspaceFilePath: string;
|
workspaceFilePath: string;
|
||||||
waitTime: number;
|
waitTime: number;
|
||||||
}
|
}
|
||||||
|
@ -61,29 +61,20 @@ export class Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(): Promise<any> {
|
async start(): Promise<any> {
|
||||||
this.options.workspacePath = this.options.folderPath;
|
|
||||||
await this._start();
|
await this._start();
|
||||||
await this.code.waitForElement('.explorer-folders-view');
|
await this.code.waitForElement('.explorer-folders-view');
|
||||||
await this.code.waitForActiveElement(`.editor-instance[id="workbench.editor.walkThroughPart"] > div > div[tabIndex="0"]`);
|
await this.code.waitForActiveElement(`.editor-instance[id="workbench.editor.walkThroughPart"] > div > div[tabIndex="0"]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async restart(options: { workspaceFilePath?: string, userDataDir?: string, extraArgs?: string[] }): Promise<any> {
|
async restart(options: { workspaceOrFolder?: string, extraArgs?: string[] }): Promise<any> {
|
||||||
await this.stop();
|
await this.stop();
|
||||||
await new Promise(c => setTimeout(c, 1000));
|
await new Promise(c => setTimeout(c, 1000));
|
||||||
Object.keys(options).forEach(key => {
|
await this._start(options.workspaceOrFolder, options.extraArgs);
|
||||||
if (options[key] === null || options[key] === undefined) {
|
|
||||||
delete options[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.options = { ...this.options, ...options };
|
|
||||||
this.options.workspacePath = options.workspaceFilePath ? options.workspaceFilePath : this.options.workspacePath;
|
|
||||||
await this._start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _start(): Promise<any> {
|
private async _start(workspaceOrFolder = this.options.workspacePath, extraArgs: string[] = []): Promise<any> {
|
||||||
cp.execSync('git checkout .', { cwd: this.options.folderPath });
|
cp.execSync('git checkout .', { cwd: this.options.workspacePath });
|
||||||
this._code = await spawn(this.options);
|
await this.startApplication(workspaceOrFolder, extraArgs);
|
||||||
this._workbench = new Workbench(this._code, this.userDataPath);
|
|
||||||
await this.checkWindowReady();
|
await this.checkWindowReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +98,21 @@ export class Application {
|
||||||
return this.code.capturePage();
|
return this.code.capturePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async startApplication(workspaceOrFolder: string, extraArgs: string[] = []): Promise<any> {
|
||||||
|
this._code = await spawn({
|
||||||
|
codePath: this.options.codePath,
|
||||||
|
workspacePath: workspaceOrFolder,
|
||||||
|
userDataDir: this.options.userDataDir,
|
||||||
|
extensionsPath: this.options.extensionsPath,
|
||||||
|
logger: this.options.logger,
|
||||||
|
verbose: this.options.verbose,
|
||||||
|
log: this.options.log,
|
||||||
|
extraArgs,
|
||||||
|
});
|
||||||
|
|
||||||
|
this._workbench = new Workbench(this._code, this.userDataPath);
|
||||||
|
}
|
||||||
|
|
||||||
private async checkWindowReady(): Promise<any> {
|
private async checkWindowReady(): Promise<any> {
|
||||||
if (!this.code) {
|
if (!this.code) {
|
||||||
console.error('No code instance found');
|
console.error('No code instance found');
|
||||||
|
|
|
@ -13,7 +13,7 @@ export function setup() {
|
||||||
|
|
||||||
// restart with preventing additional windows from restoring
|
// restart with preventing additional windows from restoring
|
||||||
// to ensure the window after restart is the multi-root workspace
|
// to ensure the window after restart is the multi-root workspace
|
||||||
await app.restart({ workspaceFilePath: app.workspaceFilePath, extraArgs: ['--disable-restore-windows'] });
|
await app.restart({ workspaceOrFolder: app.workspaceFilePath, extraArgs: ['--disable-restore-windows'] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows results from all folders', async function () {
|
it('shows results from all folders', async function () {
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
||||||
*--------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
import * as path from 'path';
|
|
||||||
import { Application } from '../../application';
|
|
||||||
|
|
||||||
export function setup() {
|
|
||||||
describe('Launch', () => {
|
|
||||||
it(`verifies that application launches when user data directory has non-ascii characters`, async function () {
|
|
||||||
const app = this.app as Application;
|
|
||||||
await app.restart({ userDataDir: path.join(app.userDataPath, 'abcdø') });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -27,7 +27,6 @@ import { setup as setupDataExtensionTests } from './areas/extensions/extensions.
|
||||||
import { setup as setupTerminalTests } from './areas/terminal/terminal.test';
|
import { setup as setupTerminalTests } from './areas/terminal/terminal.test';
|
||||||
import { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.test';
|
import { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.test';
|
||||||
import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
|
import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
|
||||||
import { setup as setupLaunchTests } from './areas/workbench/launch.test';
|
|
||||||
import { MultiLogger, Logger, ConsoleLogger, FileLogger } from './logger';
|
import { MultiLogger, Logger, ConsoleLogger, FileLogger } from './logger';
|
||||||
|
|
||||||
const tmpDir = tmp.dirSync({ prefix: 't' }) as { name: string; removeCallback: Function; };
|
const tmpDir = tmp.dirSync({ prefix: 't' }) as { name: string; removeCallback: Function; };
|
||||||
|
@ -54,7 +53,7 @@ const opts = minimist(args, {
|
||||||
|
|
||||||
const workspaceFilePath = path.join(testDataPath, 'smoketest.code-workspace');
|
const workspaceFilePath = path.join(testDataPath, 'smoketest.code-workspace');
|
||||||
const testRepoUrl = 'https://github.com/Microsoft/vscode-smoketest-express';
|
const testRepoUrl = 'https://github.com/Microsoft/vscode-smoketest-express';
|
||||||
const folderPath = path.join(testDataPath, 'vscode-smoketest-express');
|
const workspacePath = path.join(testDataPath, 'vscode-smoketest-express');
|
||||||
const extensionsPath = path.join(testDataPath, 'extensions-dir');
|
const extensionsPath = path.join(testDataPath, 'extensions-dir');
|
||||||
mkdirp.sync(extensionsPath);
|
mkdirp.sync(extensionsPath);
|
||||||
|
|
||||||
|
@ -159,13 +158,13 @@ async function createWorkspaceFile(): Promise<void> {
|
||||||
const workspace = {
|
const workspace = {
|
||||||
folders: [
|
folders: [
|
||||||
{
|
{
|
||||||
path: toUri(path.join(folderPath, 'public'))
|
path: toUri(path.join(workspacePath, 'public'))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: toUri(path.join(folderPath, 'routes'))
|
path: toUri(path.join(workspacePath, 'routes'))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: toUri(path.join(folderPath, 'views'))
|
path: toUri(path.join(workspacePath, 'views'))
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -176,22 +175,22 @@ async function createWorkspaceFile(): Promise<void> {
|
||||||
async function setupRepository(): Promise<void> {
|
async function setupRepository(): Promise<void> {
|
||||||
if (opts['test-repo']) {
|
if (opts['test-repo']) {
|
||||||
console.log('*** Copying test project repository:', opts['test-repo']);
|
console.log('*** Copying test project repository:', opts['test-repo']);
|
||||||
rimraf.sync(folderPath);
|
rimraf.sync(workspacePath);
|
||||||
// not platform friendly
|
// not platform friendly
|
||||||
cp.execSync(`cp -R "${opts['test-repo']}" "${folderPath}"`);
|
cp.execSync(`cp -R "${opts['test-repo']}" "${workspacePath}"`);
|
||||||
} else {
|
} else {
|
||||||
if (!fs.existsSync(folderPath)) {
|
if (!fs.existsSync(workspacePath)) {
|
||||||
console.log('*** Cloning test project repository...');
|
console.log('*** Cloning test project repository...');
|
||||||
cp.spawnSync('git', ['clone', testRepoUrl, folderPath]);
|
cp.spawnSync('git', ['clone', testRepoUrl, workspacePath]);
|
||||||
} else {
|
} else {
|
||||||
console.log('*** Cleaning test project repository...');
|
console.log('*** Cleaning test project repository...');
|
||||||
cp.spawnSync('git', ['fetch'], { cwd: folderPath });
|
cp.spawnSync('git', ['fetch'], { cwd: workspacePath });
|
||||||
cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: folderPath });
|
cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: workspacePath });
|
||||||
cp.spawnSync('git', ['clean', '-xdf'], { cwd: folderPath });
|
cp.spawnSync('git', ['clean', '-xdf'], { cwd: workspacePath });
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('*** Running yarn...');
|
console.log('*** Running yarn...');
|
||||||
cp.execSync('yarn', { cwd: folderPath, stdio: 'inherit' });
|
cp.execSync('yarn', { cwd: workspacePath, stdio: 'inherit' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +221,7 @@ function createApp(quality: Quality): Application {
|
||||||
return new Application({
|
return new Application({
|
||||||
quality,
|
quality,
|
||||||
codePath: opts.build,
|
codePath: opts.build,
|
||||||
folderPath,
|
workspacePath,
|
||||||
workspacePath: folderPath,
|
|
||||||
userDataDir,
|
userDataDir,
|
||||||
extensionsPath,
|
extensionsPath,
|
||||||
workspaceFilePath,
|
workspaceFilePath,
|
||||||
|
@ -310,5 +308,4 @@ describe('Test', () => {
|
||||||
setupTerminalTests();
|
setupTerminalTests();
|
||||||
setupDataMultirootTests();
|
setupDataMultirootTests();
|
||||||
setupDataLocalizationTests();
|
setupDataLocalizationTests();
|
||||||
setupLaunchTests();
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue