Skip to content

Commit

Permalink
Merge pull request #36561 from margelo/fix/prevent-tests-from-running…
Browse files Browse the repository at this point in the history
…-too-long

[NoQA] dev: fail e2e tests after three errors
  • Loading branch information
mountiny committed Feb 15, 2024
2 parents 98a51b3 + 482ec63 commit 69ac0d7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/e2e/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ const runTests = async () => {

// We run each test multiple time to average out the results
const testLog = Logger.progressInfo('');
// For each test case we allow the test to fail three times before we stop the test run:
const errorCountRef = {
errorCount: 0,
allowedExceptions: 3,
};
for (let i = 0; i < config.RUNS; i++) {
progressText = `Suite '${suite.name}' [${suiteIndex + 1}/${suites.length}], iteration [${i + 1}/${config.RUNS}]\n`;
testLog.updateText(progressText);
Expand All @@ -341,9 +346,11 @@ const runTests = async () => {

const onError = (e) => {
testLog.done();
if (i === 0) {
errorCountRef.errorCount += 1;
if (i === 0 || errorCountRef.errorCount === errorCountRef.allowedExceptions) {
// If the error happened on the first test run, the test is broken
// and we should not continue running it
// and we should not continue running it. Or if we have reached the
// maximum number of allowed exceptions, we should stop the test run.
throw e;
}
console.error(e);
Expand Down

0 comments on commit 69ac0d7

Please sign in to comment.