mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 22:41:31 +01:00
Smoke test for multi root (#31059)
* wip * fix for windows * add some tests * only run multi root test on windows * fix bug with opening files into a workspace that opens (enables smoke test) * document how to run against out of source * enable test for all OS
This commit is contained in:
@@ -11,6 +11,7 @@ const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const tempFolder = 'test_data';
|
||||
const codeWorkspace = path.join(process.cwd(), tempFolder, 'smoketest.code-workspace');
|
||||
const testRepoUrl = 'https://github.com/Microsoft/vscode-smoketest-express';
|
||||
const testRepoLocalDir = path.join(process.cwd(), `${tempFolder}/vscode-smoketest-express`);
|
||||
const keybindingsUrl = 'https://raw.githubusercontent.com/Microsoft/vscode-docs/master/scripts/keybindings';
|
||||
@@ -50,6 +51,7 @@ process.env.SMOKETEST_REPO = testRepoLocalDir;
|
||||
if (program.stable && program.stable.toLowerCase().startsWith('insiders')) {
|
||||
process.env.VSCODE_EDITION = 'insiders';
|
||||
}
|
||||
process.env.VSCODE_WORKSPACE_PATH = codeWorkspace;
|
||||
|
||||
// Setting up 'vscode-smoketest-express' project
|
||||
let os = process.platform.toString();
|
||||
@@ -63,6 +65,11 @@ else if (os === 'win32') {
|
||||
var promises: Promise<any>[] = [];
|
||||
|
||||
promises.push(getKeybindings(`${keybindingsUrl}/doc.keybindings.${os}.json`, `${tempFolder}/keybindings.json`));
|
||||
promises.push(createWorkspaceFile(codeWorkspace, [
|
||||
toUri(path.join(testRepoLocalDir, 'public')),
|
||||
toUri(path.join(testRepoLocalDir, 'routes')),
|
||||
toUri(path.join(testRepoLocalDir, 'views'))
|
||||
]));
|
||||
promises.push(cleanOrClone(testRepoUrl, testRepoLocalDir));
|
||||
|
||||
Promise.all(promises)
|
||||
@@ -77,6 +84,14 @@ function fail(errorMessage): void {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function toUri(path: string): string {
|
||||
if (os === 'win') {
|
||||
return `file:///${path.replace(/\\/g, '/')}`;
|
||||
}
|
||||
|
||||
return `file://${path}`;
|
||||
}
|
||||
|
||||
function runTests(): void {
|
||||
console.log('Running tests...');
|
||||
var proc = child_process.spawn(process.execPath, [
|
||||
@@ -183,6 +198,30 @@ function getKeybindings(url: string, location: string): Promise<any> {
|
||||
});
|
||||
}
|
||||
|
||||
function createWorkspaceFile(path: string, folders: string[]): Promise<any> {
|
||||
console.log(`Creating workspace file at ${path}...`);
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.exists(path, exists => {
|
||||
if (exists) {
|
||||
return resolve();
|
||||
}
|
||||
|
||||
const workspace = {
|
||||
id: (Date.now() + Math.round(Math.random() * 1000)).toString(),
|
||||
folders
|
||||
};
|
||||
|
||||
fs.writeFile(path, JSON.stringify(workspace, null, '\t'), error => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function folderExists(folder: string): boolean {
|
||||
try {
|
||||
fs.accessSync(folder, 'rw');
|
||||
|
||||
@@ -12,6 +12,7 @@ var path = require('path');
|
||||
export const LATEST_PATH = process.env.VSCODE_LATEST_PATH;
|
||||
export const STABLE_PATH = process.env.VSCODE_STABLE_PATH;
|
||||
export const WORKSPACE_PATH = process.env.SMOKETEST_REPO;
|
||||
export const CODE_WORKSPACE_PATH = process.env.VSCODE_WORKSPACE_PATH;
|
||||
export const USER_DIR = 'test_data/temp_user_dir';
|
||||
export const EXTENSIONS_DIR = 'test_data/temp_extensions_dir';
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import { testStatusbar } from "./tests/statusbar";
|
||||
import { testTasks } from "./tests/tasks";
|
||||
import { testExtensions } from "./tests/extensions";
|
||||
import { testLocalization } from "./tests/localization";
|
||||
import { testMultiRoot } from "./tests/multiroot";
|
||||
|
||||
describe('Smoke Test Suite', () => {
|
||||
testDataMigration();
|
||||
@@ -33,4 +34,5 @@ describe('Smoke Test Suite', () => {
|
||||
testTasks();
|
||||
testExtensions();
|
||||
testLocalization();
|
||||
testMultiRoot();
|
||||
});
|
||||
42
test/smoke/src/tests/multiroot.ts
Normal file
42
test/smoke/src/tests/multiroot.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
|
||||
import { SpectronApplication, LATEST_PATH, CODE_WORKSPACE_PATH } from "../spectron/application";
|
||||
import { CommonActions } from '../areas/common';
|
||||
|
||||
let app: SpectronApplication;
|
||||
let common: CommonActions;
|
||||
|
||||
export function testMultiRoot() {
|
||||
context('Multi Root', () => {
|
||||
|
||||
beforeEach(async function () {
|
||||
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [CODE_WORKSPACE_PATH]);
|
||||
common = new CommonActions(app);
|
||||
|
||||
return await app.start();
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
return await app.stop();
|
||||
});
|
||||
|
||||
it('shows results from all folders', async function () {
|
||||
await common.openQuickOpen();
|
||||
await common.type('*.*');
|
||||
await app.wait();
|
||||
const elCount = await common.getQuickOpenElements();
|
||||
assert.equal(elCount, 6);
|
||||
});
|
||||
|
||||
it('shows workspace name in title', async function () {
|
||||
await app.wait();
|
||||
const title = await common.getWindowTitle();
|
||||
assert.ok(title.indexOf('smoketest (Workspace)') >= 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user