mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00: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:
parent
83fe9ed9f7
commit
4f074abe22
|
@ -410,7 +410,8 @@ export class WindowsManager implements IWindowsMainService {
|
|||
|
||||
// Handle files to open/diff or to create when we dont open a folder and we do not restore any folder/untitled from hot-exit
|
||||
const usedWindows: CodeWindow[] = [];
|
||||
if (!foldersToOpen.length && !foldersToRestore.length && !emptyToRestore.length && (filesToOpen.length > 0 || filesToCreate.length > 0 || filesToDiff.length > 0)) {
|
||||
const potentialWindowsCount = foldersToOpen.length + foldersToRestore.length + workspacesToOpen.length + workspacesToRestore.length + emptyToRestore.length;
|
||||
if (potentialWindowsCount === 0 && (filesToOpen.length > 0 || filesToCreate.length > 0 || filesToDiff.length > 0)) {
|
||||
|
||||
// Find suitable window or folder path to open files in
|
||||
const fileToCheck = filesToOpen[0] || filesToCreate[0] || filesToDiff[0];
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
- Run `npm install`
|
||||
- Start the tests: `npm test -- --latest "path/to/binary"`.
|
||||
|
||||
If you want to include 'Data Migration' area tests use `npm test -- --latest path/to/binary --stable path/to/currentStable` respectively.
|
||||
If you want to include 'Data Migration' area tests use `npm test -- --latest path/to/binary --stable path/to/currentStable` respectively.
|
||||
|
||||
Detailed prerequisites and running steps are described [in our smoke test wiki](https://github.com/Microsoft/vscode/wiki/Smoke-Test#automated-smoke-test).
|
||||
|
||||
|
@ -48,3 +48,15 @@ To add new test, `./test/${area}.ts` should be updated. The same instruction-sty
|
|||
|
||||
# Screenshots
|
||||
Almost on every automated test action it captures a screenshot. These help to determine an issue, if smoke test fails. The normal workflow is that you understand what code is doing and then try to match it up with screenshots obtained from the test.
|
||||
|
||||
# Running "Out of Sources"
|
||||
If you did a fix in VS Code that you need in order for the smoke test to succeed, here is how you can run the smoke test against the sources of VS Code:
|
||||
* Set related environment variables in the console:
|
||||
* `export NODE_ENV=development`
|
||||
* `export VSCODE_DEV=1`
|
||||
* `export VSCODE_CLI=1`
|
||||
* open `application.ts`
|
||||
* pass in the vscode folder as argument to the application
|
||||
* e.g. instead of `args: args` type `args: ['/Users/bpasero/Development/vscode', ...args]`
|
||||
* run `npm test -- --latest <path to electron>`
|
||||
* e.g. on macOS: `npm test -- --latest <path to vscode>/.build/electron/Code\ -\ OSS.app/Contents/MacOS/Electron`
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue