diff --git a/test/smoke/src/areas/search/search.test.ts b/test/smoke/src/areas/search/search.test.ts index 4ccb8634a42..3e3401fc7a3 100644 --- a/test/smoke/src/areas/search/search.test.ts +++ b/test/smoke/src/areas/search/search.test.ts @@ -6,18 +6,17 @@ import * as cp from 'child_process'; import minimist = require('minimist'); import { Application } from '../../../../automation'; -import { afterSuite, beforeSuite } from '../../utils'; +import { afterSuite, beforeSuite, retry } from '../../utils'; export function setup(opts: minimist.ParsedArgs) { // https://github.com/microsoft/vscode/issues/115244 - // https://github.com/microsoft/vscode/issues/132218 - (process.platform === 'win32' ? describe.skip : describe)('Search', () => { + describe('Search', () => { beforeSuite(opts); after(function () { const app = this.app as Application; - cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder }); - cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }); + retry(async () => cp.execSync('git checkout . --quiet', { cwd: app.workspacePathOrFolder }), 0, 5); + retry(async () => cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }), 0, 5); }); afterSuite(opts); diff --git a/test/smoke/src/utils.ts b/test/smoke/src/utils.ts index f6d25bd5009..727a994e6de 100644 --- a/test/smoke/src/utils.ts +++ b/test/smoke/src/utils.ts @@ -68,3 +68,23 @@ export function timeout(i: number) { }, i); }); } + +export interface ITask { + (): T; +} + +export async function retry(task: ITask>, delay: number, retries: number): Promise { + let lastError: Error | undefined; + + for (let i = 0; i < retries; i++) { + try { + return await task(); + } catch (error) { + lastError = error; + + await timeout(delay); + } + } + + throw lastError; +}