Skip to content

Commit 7ba9027

Browse files
committed
Increase scenarios in which retries will be used
This will update the `jest-runner-vscode` patch to retry tests that fail due to no test result being returned from the test runner. This will also add some retries to the `minimal-workspace` and `no-workspace` tests to help with flakiness.
1 parent 9a9a8c5 commit 7ba9027

3 files changed

Lines changed: 31 additions & 36 deletions

File tree

extensions/ql-vscode/patches/jest-runner-vscode+3.0.1.patch

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ index 8657ace..4d35409 100644
4141
-export default function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig, filterOutput, onStart, onResult, onFailure, ipc, quiet, }: RunVSCodeOptions): Promise<void>;
4242
+export default function runVSCode(options: RunVSCodeOptions): Promise<void>;
4343
diff --git a/node_modules/jest-runner-vscode/dist/run-vscode.js b/node_modules/jest-runner-vscode/dist/run-vscode.js
44-
index 5d8e513..cacbc42 100644
44+
index 5d8e513..7e556ee 100644
4545
--- a/node_modules/jest-runner-vscode/dist/run-vscode.js
4646
+++ b/node_modules/jest-runner-vscode/dist/run-vscode.js
4747
@@ -5,8 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -78,44 +78,37 @@ index 5d8e513..cacbc42 100644
7878
if (!silent && !filterOutput) {
7979
vscode.stdout.pipe(process.stdout);
8080
vscode.stderr.pipe(process.stderr);
81-
@@ -101,11 +115,31 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
81+
@@ -99,6 +113,29 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
82+
exited = true;
83+
const exit = code ?? signal ?? '<unknown>';
8284
const message = `VS Code exited with exit code ${exit}`;
85+
+ const currentAttempt = attempt ?? 0;
86+
+ const incompleteTests = tests.some(test => !completedTests.has(test));
87+
+ if (maxRetries &&
88+
+ maxRetries > 0 &&
89+
+ currentAttempt < maxRetries &&
90+
+ incompleteTests) {
91+
+ silent || quiet || log(message);
92+
+ const newAttempt = currentAttempt + 1;
93+
+ const newTests = tests.filter(test => !completedTests.has(test));
94+
+ ipc.server.off('testFileResult', onTestFileResult);
95+
+ ipc.server.off('testStart', onTestStart);
96+
+ ipc.server.off('testFileStart', onTestStart);
97+
+ ipc.server.off('stdout', onStdout);
98+
+ ipc.server.off('stderr', onStderr);
99+
+ ipc.server.off('error', onError);
100+
+ await runVSCode({
101+
+ ...options,
102+
+ tests: newTests,
103+
+ attempt: newAttempt,
104+
+ });
105+
+ resolve();
106+
+ return;
107+
+ }
83108
if (typeof code !== 'number' || code !== 0) {
84109
silent || quiet || console_1.default.error(message);
85-
- const error = vscodeError ?? childError ?? new Error(message);
86-
- for (const test of tests) {
87-
- const completed = completedTests.has(test);
88-
- if (!completed) {
89-
- await onFailure(test, error);
90-
+ const currentAttempt = attempt ?? 0;
91-
+ if (maxRetries && maxRetries > 0 && currentAttempt < maxRetries) {
92-
+ const newAttempt = currentAttempt + 1;
93-
+ const newTests = tests.filter(test => !completedTests.has(test));
94-
+ ipc.server.off('testFileResult', onTestFileResult);
95-
+ ipc.server.off('testStart', onTestStart);
96-
+ ipc.server.off('testFileStart', onTestStart);
97-
+ ipc.server.off('stdout', onStdout);
98-
+ ipc.server.off('stderr', onStderr);
99-
+ ipc.server.off('error', onError);
100-
+ await runVSCode({
101-
+ ...options,
102-
+ tests: newTests,
103-
+ attempt: newAttempt,
104-
+ });
105-
+ resolve();
106-
+ return;
107-
+ }
108-
+ else {
109-
+ const error = vscodeError ?? childError ?? new Error(message);
110-
+ for (const test of tests) {
111-
+ const completed = completedTests.has(test);
112-
+ if (!completed) {
113-
+ await onFailure(test, error);
114-
+ }
115-
}
116-
}
117-
}
118-
@@ -138,3 +172,6 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
110+
const error = vscodeError ?? childError ?? new Error(message);
111+
@@ -138,3 +175,6 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
119112
});
120113
}
121114
exports.default = runVSCode;

extensions/ql-vscode/src/vscode-tests/minimal-workspace/jest-runner-vscode.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const config = {
1313
"--disable-extensions",
1414
path.resolve(rootDir, "test/data"),
1515
],
16+
retries: 1,
1617
};
1718

1819
module.exports = config;

extensions/ql-vscode/src/vscode-tests/no-workspace/jest-runner-vscode.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { config: baseConfig } = require("../jest-runner-vscode.config.base");
44
const config = {
55
...baseConfig,
66
launchArgs: [...(baseConfig.launchArgs ?? []), "--disable-extensions"],
7+
retries: 1,
78
};
89

910
module.exports = config;

0 commit comments

Comments
 (0)