Skip to content

Commit

Permalink
test: reduce flakiness of test-runner-output.mjs
Browse files Browse the repository at this point in the history
This commit is similar to #51952. When the system is under load
it is possible for these timeout tests to become flaky. We
work around that by using a much longer setTimeout() in the test
so that it is not racing against the test's timeout. But, we have
to unref() such a large timeout. And, because test timeouts do
not currently keep the event loop alive, we use a different
setTimeout() for that purpose.

Fixes: #52139
Refs: #52140
PR-URL: #52146
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
  • Loading branch information
cjihrig authored and marco-ippolito committed May 3, 2024
1 parent e4981b3 commit d7bfb4e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 46 deletions.
100 changes: 56 additions & 44 deletions test/fixtures/test-runner/output/lcov_reporter.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,26 @@ FN:310,anonymous_77
FN:313,anonymous_78
FN:318,anonymous_79
FN:319,anonymous_80
FN:324,anonymous_81
FN:329,anonymous_82
FN:330,anonymous_83
FN:320,anonymous_81
FN:327,anonymous_82
FN:328,anonymous_83
FN:335,anonymous_84
FN:339,anonymous_85
FN:342,get then
FN:336,anonymous_85
FN:341,anonymous_86
FN:345,anonymous_87
FN:350,anonymous_88
FN:353,get then
FN:348,get then
FN:351,anonymous_89
FN:356,anonymous_90
FN:361,anonymous_91
FN:359,get then
FN:362,anonymous_92
FN:363,anonymous_93
FN:367,anonymous_94
FN:368,anonymous_95
FN:369,anonymous_96
FN:375,anonymous_97
FN:379,anonymous_98
FN:367,anonymous_93
FN:368,anonymous_94
FN:369,anonymous_95
FN:373,anonymous_96
FN:374,anonymous_97
FN:375,anonymous_98
FN:381,anonymous_99
FN:385,anonymous_100
FNDA:1,anonymous_0
FNDA:1,anonymous_1
FNDA:1,anonymous_2
Expand Down Expand Up @@ -185,21 +187,23 @@ FNDA:1,anonymous_82
FNDA:1,anonymous_83
FNDA:1,anonymous_84
FNDA:1,anonymous_85
FNDA:1,get then
FNDA:1,anonymous_86
FNDA:1,anonymous_87
FNDA:1,anonymous_88
FNDA:1,get then
FNDA:1,anonymous_89
FNDA:1,anonymous_90
FNDA:1,anonymous_91
FNDA:1,get then
FNDA:1,anonymous_92
FNDA:1,anonymous_93
FNDA:1,anonymous_94
FNDA:1,anonymous_95
FNDA:1,anonymous_96
FNDA:1,anonymous_97
FNDA:1,anonymous_98
FNF:99
FNH:96
FNDA:1,anonymous_99
FNDA:1,anonymous_100
FNF:101
FNH:98
BRDA:1,0,0,1
BRDA:8,1,0,1
BRDA:12,2,0,1
Expand Down Expand Up @@ -279,30 +283,32 @@ BRDA:310,75,0,1
BRDA:313,76,0,1
BRDA:318,77,0,1
BRDA:319,78,0,1
BRDA:324,79,0,1
BRDA:329,80,0,1
BRDA:330,81,0,1
BRDA:320,79,0,1
BRDA:327,80,0,1
BRDA:328,81,0,1
BRDA:335,82,0,1
BRDA:339,83,0,1
BRDA:342,84,0,1
BRDA:343,85,0,0
BRDA:345,86,0,1
BRDA:350,87,0,1
BRDA:353,88,0,1
BRDA:354,89,0,0
BRDA:356,90,0,1
BRDA:361,91,0,1
BRDA:364,92,0,0
BRDA:362,93,0,1
BRDA:363,94,0,1
BRDA:367,95,0,1
BRDA:370,96,0,0
BRDA:368,97,0,1
BRDA:369,98,0,1
BRDA:375,99,0,1
BRDA:379,100,0,1
BRF:101
BRH:97
BRDA:336,83,0,1
BRDA:341,84,0,1
BRDA:345,85,0,1
BRDA:348,86,0,1
BRDA:349,87,0,0
BRDA:351,88,0,1
BRDA:356,89,0,1
BRDA:359,90,0,1
BRDA:360,91,0,0
BRDA:362,92,0,1
BRDA:367,93,0,1
BRDA:370,94,0,0
BRDA:368,95,0,1
BRDA:369,96,0,1
BRDA:373,97,0,1
BRDA:376,98,0,0
BRDA:374,99,0,1
BRDA:375,100,0,1
BRDA:381,101,0,1
BRDA:385,102,0,1
BRF:103
BRH:99
DA:1,1
DA:2,1
DA:3,1
Expand Down Expand Up @@ -702,6 +708,12 @@ DA:396,1
DA:397,1
DA:398,1
DA:399,1
LH:397
LF:399
DA:400,1
DA:401,1
DA:402,1
DA:403,1
DA:404,1
DA:405,1
LH:403
LF:405
end_of_record
10 changes: 8 additions & 2 deletions test/fixtures/test-runner/output/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,18 @@ test('subtest sync throw fails', async (t) => {

test('timed out async test', { timeout: 5 }, async (t) => {
return new Promise((resolve) => {
setTimeout(resolve, 100);
setTimeout(() => {
// Empty timer so the process doesn't exit before the timeout triggers.
}, 5);
setTimeout(resolve, 30_000_000).unref();
});
});

test('timed out callback test', { timeout: 5 }, (t, done) => {
setTimeout(done, 100);
setTimeout(() => {
// Empty timer so the process doesn't exit before the timeout triggers.
}, 5);
setTimeout(done, 30_000_000).unref();
});


Expand Down

0 comments on commit d7bfb4e

Please sign in to comment.