Add retries of CLI integration tests
This will patch `jest-runner-vscode` to retry tests. This is a temporary test to see if this will help with the flakiness of the CLI integration tests. The biggest problem with this is that it will launch multiple VSCode instances on every retry: - First try (not a retry): 1 instance - Second try: 2 instances - Third try: 3 instances - etc. I'm not sure why this is happening and can't really narrow it down to a specific cause. Even if I change the `runVSCode` call for the retry by a simple `cp.spawn` call, it still launches multiple instances.
This commit is contained in:
@@ -17,3 +17,89 @@ index 0663c5c..4991663 100644
|
||||
const options = JSON.parse(PARENT_JEST_OPTIONS);
|
||||
const jestOptions = [
|
||||
...options.args,
|
||||
diff --git a/node_modules/jest-runner-vscode/dist/public-types.d.ts b/node_modules/jest-runner-vscode/dist/public-types.d.ts
|
||||
index 57716e5..d8614af 100644
|
||||
--- a/node_modules/jest-runner-vscode/dist/public-types.d.ts
|
||||
+++ b/node_modules/jest-runner-vscode/dist/public-types.d.ts
|
||||
@@ -59,4 +59,5 @@ export interface RunnerOptions {
|
||||
* code, or download progress. Defaults to `false`.
|
||||
*/
|
||||
quiet?: boolean;
|
||||
+ retries?: number;
|
||||
}
|
||||
diff --git a/node_modules/jest-runner-vscode/dist/run-vscode.d.ts b/node_modules/jest-runner-vscode/dist/run-vscode.d.ts
|
||||
index 8657ace..4d35409 100644
|
||||
--- a/node_modules/jest-runner-vscode/dist/run-vscode.d.ts
|
||||
+++ b/node_modules/jest-runner-vscode/dist/run-vscode.d.ts
|
||||
@@ -16,5 +16,7 @@ export declare type RunVSCodeOptions = {
|
||||
onFailure: JestRunner.OnTestFailure;
|
||||
ipc: InstanceType<typeof IPC>;
|
||||
quiet?: boolean;
|
||||
+ attempt?: number;
|
||||
+ maxRetries?: number;
|
||||
};
|
||||
-export default function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig, filterOutput, onStart, onResult, onFailure, ipc, quiet, }: RunVSCodeOptions): Promise<void>;
|
||||
+export default function runVSCode(options: RunVSCodeOptions): Promise<void>;
|
||||
diff --git a/node_modules/jest-runner-vscode/dist/run-vscode.js b/node_modules/jest-runner-vscode/dist/run-vscode.js
|
||||
index 5d8e513..6edf99a 100644
|
||||
--- a/node_modules/jest-runner-vscode/dist/run-vscode.js
|
||||
+++ b/node_modules/jest-runner-vscode/dist/run-vscode.js
|
||||
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const child_process_1 = __importDefault(require("child_process"));
|
||||
const console_1 = __importDefault(require("console"));
|
||||
-async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig, filterOutput, onStart, onResult, onFailure, ipc, quiet, }) {
|
||||
+async function runVSCode(options) {
|
||||
+ const { vscodePath, args, jestArgs, env, tests, globalConfig, filterOutput, onStart, onResult, onFailure, ipc, quiet, attempt, maxRetries, } = options;
|
||||
return await new Promise(resolve => {
|
||||
const useStdErr = globalConfig.json || globalConfig.useStderr;
|
||||
const log = useStdErr
|
||||
@@ -101,11 +102,31 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
|
||||
const message = `VS Code exited with exit code ${exit}`;
|
||||
if (typeof code !== 'number' || code !== 0) {
|
||||
silent || quiet || console_1.default.error(message);
|
||||
- const error = vscodeError ?? childError ?? new Error(message);
|
||||
- for (const test of tests) {
|
||||
- const completed = completedTests.has(test);
|
||||
- if (!completed) {
|
||||
- await onFailure(test, error);
|
||||
+ const currentAttempt = attempt ?? 0;
|
||||
+ if (maxRetries && maxRetries > 0 && currentAttempt < maxRetries) {
|
||||
+ const newAttempt = currentAttempt + 1;
|
||||
+ const newTests = tests.filter(test => !completedTests.has(test));
|
||||
+ ipc.server.off('testFileResult', onTestFileResult);
|
||||
+ ipc.server.off('testStart', onTestStart);
|
||||
+ ipc.server.off('testFileStart', onTestStart);
|
||||
+ ipc.server.off('stdout', onStdout);
|
||||
+ ipc.server.off('stderr', onStderr);
|
||||
+ ipc.server.off('error', onError);
|
||||
+ await runVSCode({
|
||||
+ ...options,
|
||||
+ tests: newTests,
|
||||
+ attempt: newAttempt,
|
||||
+ });
|
||||
+ resolve();
|
||||
+ return;
|
||||
+ }
|
||||
+ else {
|
||||
+ const error = vscodeError ?? childError ?? new Error(message);
|
||||
+ for (const test of tests) {
|
||||
+ const completed = completedTests.has(test);
|
||||
+ if (!completed) {
|
||||
+ await onFailure(test, error);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/node_modules/jest-runner-vscode/dist/runner.js b/node_modules/jest-runner-vscode/dist/runner.js
|
||||
index e24c976..c374022 100644
|
||||
--- a/node_modules/jest-runner-vscode/dist/runner.js
|
||||
+++ b/node_modules/jest-runner-vscode/dist/runner.js
|
||||
@@ -107,6 +107,7 @@ class VSCodeTestRunner {
|
||||
onFailure,
|
||||
ipc,
|
||||
quiet: vscodeOptions.quiet,
|
||||
+ maxRetries: vscodeOptions.retries,
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -25,6 +25,7 @@ const config = {
|
||||
...baseConfig.extensionTestsEnv,
|
||||
INTEGRATION_TEST_MODE: "true",
|
||||
},
|
||||
retries: 3,
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
|
||||
Reference in New Issue
Block a user