Skip to content

Commit 84fd591

Browse files
authored
Chore: Increase Mocha timeout for copying fixtures (#13768)
For the last several weeks, our CI jobs have been flaky due to test hook timeouts on the Windows and macOS runners. I traced most of the failures to four `before` hooks that copy the test fixtures to a temporary directory. They usually take ~2.5s, but that occasionally spikes to tens of seconds: in the two times I was able to repro the timeouts, the slowest copy jobs were 25 and 32 seconds. Rather than increasing the global test timeout, I instead bumped it just for these four hooks that were causing problems.
1 parent 1faeb84 commit 84fd591

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

tests/lib/cli-engine/cli-engine.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ describe("CLIEngine", () => {
102102
}
103103

104104
// copy into clean area so as not to get "infected" by this project's .eslintrc files
105-
before(() => {
105+
before(function() {
106+
107+
/*
108+
* GitHub Actions Windows and macOS runners occasionally exhibit
109+
* extremely slow filesystem operations, during which copying fixtures
110+
* exceeds the default test timeout, so raise it just for this hook.
111+
* Mocha uses `this` to set timeouts on an individual hook level.
112+
*/
113+
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
106114
shell.mkdir("-p", fixtureDir);
107115
shell.cp("-r", "./tests/fixtures/.", fixtureDir);
108116
});

tests/lib/cli-engine/file-enumerator.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,16 @@ describe("FileEnumerator", () => {
211211
);
212212
}
213213

214-
before(() => {
214+
before(function() {
215+
216+
/*
217+
* GitHub Actions Windows and macOS runners occasionally
218+
* exhibit extremely slow filesystem operations, during which
219+
* copying fixtures exceeds the default test timeout, so raise
220+
* it just for this hook. Mocha uses `this` to set timeouts on
221+
* an individual hook level.
222+
*/
223+
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
215224
fixtureDir = `${os.tmpdir()}/eslint/tests/fixtures/`;
216225
sh.mkdir("-p", fixtureDir);
217226
sh.cp("-r", "./tests/fixtures/*", fixtureDir);

tests/lib/cli.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ describe("cli", () => {
8282
}
8383

8484
// copy into clean area so as not to get "infected" by this project's .eslintrc files
85-
before(() => {
85+
before(function() {
86+
87+
/*
88+
* GitHub Actions Windows and macOS runners occasionally exhibit
89+
* extremely slow filesystem operations, during which copying fixtures
90+
* exceeds the default test timeout, so raise it just for this hook.
91+
* Mocha uses `this` to set timeouts on an individual hook level.
92+
*/
93+
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
8694
fixtureDir = `${os.tmpdir()}/eslint/fixtures`;
8795
sh.mkdir("-p", fixtureDir);
8896
sh.cp("-r", "./tests/fixtures/.", fixtureDir);

tests/lib/eslint/eslint.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@ describe("ESLint", () => {
8686
}
8787

8888
// copy into clean area so as not to get "infected" by this project's .eslintrc files
89-
before(() => {
89+
before(function() {
90+
91+
/*
92+
* GitHub Actions Windows and macOS runners occasionally exhibit
93+
* extremely slow filesystem operations, during which copying fixtures
94+
* exceeds the default test timeout, so raise it just for this hook.
95+
* Mocha uses `this` to set timeouts on an individual hook level.
96+
*/
97+
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
9098
shell.mkdir("-p", fixtureDir);
9199
shell.cp("-r", "./tests/fixtures/.", fixtureDir);
92100
});

0 commit comments

Comments
 (0)