smoke - retry quick open search (fix #136499)

This commit is contained in:
Benjamin Pasero 2021-11-15 07:52:12 +01:00
parent 4fb384ee85
commit 6f28593438
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65
3 changed files with 49 additions and 14 deletions

View file

@ -470,7 +470,7 @@ flakySuite('Recursive Watcher (parcel)', () => {
// Restore watched path
await Promises.mkdir(watchedPath);
await timeout(200); // restart is delayed
await timeout(1500); // restart is delayed
await service.whenReady();
// Verify events come in again

View file

@ -117,8 +117,16 @@ export interface ILifecycleMainService {
quit(willRestart?: boolean): Promise<boolean /* veto */>;
/**
* Forcefully shutdown the application. The only lifecycle event handler
* that is triggered is `onWillShutdown`.
* Forcefully shutdown the application and optionally set an exit code.
*
* This method should only be used in rare situations where it is important
* to set an exit code (e.g. running tests) or when the application is
* not in a healthy state and should terminate asap.
*
* This method does not fire the normal lifecycle events to the windows,
* that normally can be vetoed. Windows are destroyed without a chance
* of components to participate. The only lifecycle event handler that
* is triggered is `onWillShutdown` in the main process.
*/
kill(code?: number): Promise<void>;
@ -590,17 +598,13 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
async kill(code?: number): Promise<void> {
this.logService.trace('Lifecycle#kill()');
// Start shutdown sequence
// Give main process participants a chance to oderly shutdown
await this.fireOnWillShutdown();
// The kill() method is only used in 2 situations:
// - when an instance fails to start at all
// - when extension tests run from CLI to report proper exit code
//
// From extension tests we have seen issues where calling app.exit()
// with an opened window can lead to native crashes (Linux) when webviews
// are involved. As such, we should make sure to destroy any opened
// window before calling app.exit().
// with an opened window can lead to native crashes (Linux). As such,
// we should make sure to destroy any opened window before calling
// `app.exit()`.
//
// Note: Electron implements a similar logic here:
// https://github.com/electron/electron/blob/fe5318d753637c3903e23fc1ed1b263025887b6a/spec-main/window-helpers.ts#L5

View file

@ -40,9 +40,40 @@ export class QuickAccess {
}
async openFile(fileName: string): Promise<void> {
await this.openQuickAccess(fileName);
let retries = 0;
let fileFound = false;
while (++retries < 10) {
let retry = false;
await this.openQuickAccess(fileName);
await this.quickInput.waitForQuickInputElements(names => {
const name = names[0];
if (name === fileName) {
fileFound = true;
return true;
}
if (name === 'No matching results') {
retry = true;
return true;
}
return false;
});
if (!retry) {
break;
}
await this.quickInput.closeQuickInput();
await new Promise(c => setTimeout(c, 500));
}
if (!fileFound) {
throw new Error(`Quick open file search was unable to find '${fileName}' after 10 attempts, giving up.`);
}
await this.quickInput.waitForQuickInputElements(names => names[0] === fileName);
await this.code.dispatchKeybinding('enter');
await this.editors.waitForActiveTab(fileName);
await this.editors.waitForEditorFocus(fileName);
@ -75,7 +106,7 @@ export class QuickAccess {
}
await this.quickInput.closeQuickInput();
await new Promise(c => setTimeout(c, 250));
await new Promise(c => setTimeout(c, 500));
}
}
}