This commit is contained in:
Benjamin Pasero 2019-03-15 18:54:18 +01:00
parent ea7c31d770
commit 4412367554
4 changed files with 88 additions and 99 deletions

View file

@ -9,7 +9,7 @@ Make sure you are on **Node v10.x**.
yarn smoketest
# Build
yarn smoketest --build PATH_TO_BUILD
yarn smoketest --build PATH_TO_BUILD --stable-build PATH_TO_STABLE_BUILD
```
### Run for a release
@ -19,7 +19,7 @@ You must always run the smoketest version which matches the release you are test
```bash
git checkout release/1.22
yarn
yarn smoketest --build PATH_TO_RELEASE_BUILD
yarn smoketest --build PATH_TO_RELEASE_BUILD --stable-build PATH_TO_STABLE_BUILD
```
### Debug

View file

@ -60,10 +60,13 @@ export class Application {
return this.options.userDataDir;
}
async start(): Promise<any> {
async start(expectWalkthroughPart = true): Promise<any> {
await this._start();
await this.code.waitForElement('.explorer-folders-view');
await this.code.waitForActiveElement(`.editor-instance[id="workbench.editor.walkThroughPart"] > div > div[tabIndex="0"]`);
if (expectWalkthroughPart) {
await this.code.waitForActiveElement(`.editor-instance[id="workbench.editor.walkThroughPart"] > div > div[tabIndex="0"]`);
}
}
async restart(options: { workspaceOrFolder?: string, extraArgs?: string[] }): Promise<any> {

View file

@ -3,109 +3,93 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, Quality } from '../../application';
import * as rimraf from 'rimraf';
import { Application, ApplicationOptions } from '../../application';
import { join } from 'path';
export interface ICreateAppFn {
(quality: Quality): Application;
}
export function setup(stableCodePath: string, testDataPath: string) {
export function setup(userDataDir: string, createApp: ICreateAppFn) {
describe('Data Migration', () => {
describe('Data Migration: This test MUST run before releasing by providing the --stable-build command line argument', () => {
it(`verifies opened editors are restored`, async function () {
if (!stableCodePath) {
this.skip();
}
afterEach(async function () {
await new Promise((c, e) => rimraf(userDataDir, { maxBusyTries: 10 }, err => err ? e(err) : c()));
const userDataDir = join(testDataPath, 'd2'); // different data dir from the other tests
const stableOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
stableOptions.codePath = stableCodePath;
stableOptions.userDataDir = userDataDir;
const stableApp = new Application(stableOptions);
await stableApp!.start();
// Open 3 editors and pin 2 of them
await stableApp.workbench.quickopen.openFile('www');
await stableApp.workbench.quickopen.runCommand('View: Keep Editor');
await stableApp.workbench.quickopen.openFile('app.js');
await stableApp.workbench.quickopen.runCommand('View: Keep Editor');
await stableApp.workbench.editors.newUntitledFile();
await stableApp.stop();
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
const insidersApp = new Application(insiderOptions);
await insidersApp!.start(false /* not expecting walkthrough parth */);
// Verify 3 editors are open
await insidersApp.workbench.editors.waitForEditorFocus('Untitled-1');
await insidersApp.workbench.editors.selectTab('app.js');
await insidersApp.workbench.editors.selectTab('www');
await insidersApp.stop();
});
// it('checks if the Untitled file is restored migrating from stable to latest', async function () {
// const stableApp = createApp(Quality.Stable);
it(`verifies that 'hot exit' works for dirty files`, async function () {
if (!stableCodePath) {
this.skip();
}
// if (!stableApp) {
// this.skip();
// return;
// }
const userDataDir = join(testDataPath, 'd3'); // different data dir from the other tests
// await stableApp.start();
const stableOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
stableOptions.codePath = stableCodePath;
stableOptions.userDataDir = userDataDir;
// const textToType = 'Very dirty file';
const stableApp = new Application(stableOptions);
await stableApp!.start();
// await stableApp.workbench.editors.newUntitledFile();
// await stableApp.workbench.editor.waitForTypeInEditor('Untitled-1', textToType);
await stableApp.workbench.editors.newUntitledFile();
// await stableApp.stop();
// await new Promise(c => setTimeout(c, 500)); // wait until all resources are released (e.g. locked local storage)
const untitled = 'Untitled-1';
const textToTypeInUntitled = 'Hello, Unitled Code';
await stableApp.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled);
// // Checking latest version for the restored state
// const app = createApp(Quality.Insiders);
const readmeMd = 'readme.md';
const textToType = 'Hello, Code';
await stableApp.workbench.quickopen.openFile(readmeMd);
await stableApp.workbench.editor.waitForTypeInEditor(readmeMd, textToType);
// await app.start(false);
await stableApp.stop();
// await app.workbench.editors.waitForActiveTab('Untitled-1', true);
// await app.workbench.editor.waitForEditorContents('Untitled-1', c => c.indexOf(textToType) > -1);
const insiderOptions: ApplicationOptions = Object.assign({}, this.defaultOptions);
insiderOptions.userDataDir = userDataDir;
// await app.stop();
// });
const insidersApp = new Application(insiderOptions);
await insidersApp!.start(false /* not expecting walkthrough parth */);
// it('checks if the newly created dirty file is restored migrating from stable to latest', async function () {
// const stableApp = createApp(Quality.Stable);
await insidersApp.workbench.editors.waitForActiveTab(readmeMd, true);
await insidersApp.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1);
// if (!stableApp) {
// this.skip();
// return;
// }
await insidersApp.workbench.editors.waitForTab(untitled, true);
await insidersApp.workbench.editors.selectTab(untitled, true);
await insidersApp.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1);
// await stableApp.start();
// const fileName = 'app.js';
// const textPart = 'This is going to be an unsaved file';
// await stableApp.workbench.quickopen.openFile(fileName);
// await stableApp.workbench.editor.waitForTypeInEditor(fileName, textPart);
// await stableApp.stop();
// await new Promise(c => setTimeout(c, 500)); // wait until all resources are released (e.g. locked local storage)
// // Checking latest version for the restored state
// const app = createApp(Quality.Insiders);
// await app.start(false);
// await app.workbench.editors.waitForActiveTab(fileName);
// await app.workbench.editor.waitForEditorContents(fileName, c => c.indexOf(textPart) > -1);
// await app.stop();
// });
// it('checks if opened tabs are restored migrating from stable to latest', async function () {
// const stableApp = createApp(Quality.Stable);
// if (!stableApp) {
// this.skip();
// return;
// }
// await stableApp.start();
// const fileName1 = 'app.js', fileName2 = 'jsconfig.json', fileName3 = 'readme.md';
// await stableApp.workbench.quickopen.openFile(fileName1);
// await stableApp.workbench.runCommand('View: Keep Editor');
// await stableApp.workbench.quickopen.openFile(fileName2);
// await stableApp.workbench.runCommand('View: Keep Editor');
// await stableApp.workbench.quickopen.openFile(fileName3);
// await stableApp.stop();
// const app = createApp(Quality.Insiders);
// await app.start(false);
// await app.workbench.editors.waitForTab(fileName1);
// await app.workbench.editors.waitForTab(fileName2);
// await app.workbench.editors.waitForTab(fileName3);
// await app.stop();
// });
await insidersApp.stop();
});
});
}

View file

@ -13,7 +13,7 @@ import * as mkdirp from 'mkdirp';
import { ncp } from 'ncp';
import { Application, Quality, ApplicationOptions } from './application';
// import { setup as setupDataMigrationTests } from './areas/workbench/data-migration.test';
import { setup as setupDataMigrationTests } from './areas/workbench/data-migration.test';
import { setup as setupDataLossTests } from './areas/workbench/data-loss.test';
import { setup as setupDataExplorerTests } from './areas/explorer/explorer.test';
import { setup as setupDataPreferencesTests } from './areas/preferences/preferences.test';
@ -113,16 +113,16 @@ function getBuildElectronPath(root: string): string {
}
let testCodePath = opts.build;
// let stableCodePath = opts['stable-build'];
let stableCodePath = opts['stable-build'];
let electronPath: string;
// let stablePath: string;
let stablePath: string | undefined = undefined;
if (testCodePath) {
electronPath = getBuildElectronPath(testCodePath);
// if (stableCodePath) {
// stablePath = getBuildElectronPath(stableCodePath);
// }
if (stableCodePath) {
stablePath = getBuildElectronPath(stableCodePath);
}
} else {
testCodePath = getDevElectronPath();
electronPath = testCodePath;
@ -135,6 +135,10 @@ if (!fs.existsSync(electronPath || '')) {
fail(`Can't find Code at ${electronPath}.`);
}
if (typeof stablePath === 'string' && !fs.existsSync(stablePath)) {
fail(`Can't find Stable Code at ${stablePath}.`);
}
const userDataDir = path.join(testDataPath, 'd');
let quality: Quality;
@ -223,9 +227,7 @@ after(async function () {
await new Promise((c, e) => rimraf(testDataPath, { maxBusyTries: 10 }, err => err ? e(err) : c()));
});
// describe('Data Migration', () => {
// setupDataMigrationTests(userDataDir, createApp);
// });
setupDataMigrationTests(stableCodePath, testDataPath);
describe('Running Code', () => {
before(async function () {