Skip to content

Commit f945f4f

Browse files
committed
more resilient tests
1 parent 9de3df4 commit f945f4f

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

test/comparison-tests/run-tests.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,37 @@ function runTests() {
8888
* @param {string} testName
8989
*/
9090
function runTestAsChildProcess(testName) {
91-
try {
92-
const testToRun = ' --test-to-run ' + testName;
93-
const testCommand =
94-
'mocha --reporter spec test/comparison-tests/create-and-execute-test.js ' +
95-
testToRun;
91+
const testToRun = ' --test-to-run ' + testName;
92+
const testCommand =
93+
'mocha --reporter spec test/comparison-tests/create-and-execute-test.js ' +
94+
testToRun;
9695

97-
const _testOutput = execSync(
98-
testCommand + (saveOutputMode ? ' --save-output' : ''),
99-
{ stdio: 'inherit' }
100-
);
101-
if (!saveOutputMode) {
102-
const _testOutput2 = execSync(
103-
testCommand + ' --extra-option experimentalFileCaching',
96+
// execution tests are flaky so allow 3 attempts
97+
let attempt = 1;
98+
let passed = false;
99+
while (!passed) {
100+
try {
101+
const _testOutput = execSync(
102+
testCommand + (saveOutputMode ? ' --save-output' : ''),
104103
{ stdio: 'inherit' }
105104
);
105+
if (!saveOutputMode) {
106+
const _testOutput2 = execSync(
107+
testCommand + ' --extra-option experimentalFileCaching',
108+
{ stdio: 'inherit' }
109+
);
110+
}
111+
passed = true
112+
} catch (err) {
113+
console.info(`Attempt ${attempt} failed...`);
114+
if (attempt >= 5) throw new Error("Failed to run test repeatedly.")
115+
attempt++;
106116
}
117+
}
107118

119+
if (passed) {
108120
passingTests.push(testName);
109-
} catch (err) {
121+
} else {
110122
failingTests.push(testName);
111123
}
112124
}

0 commit comments

Comments
 (0)