Skip to content

Commit

Permalink
Chore: Increase Mocha timeout for copying fixtures (#13768)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
btmills authored Oct 20, 2020
1 parent 1faeb84 commit 84fd591
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
10 changes: 9 additions & 1 deletion tests/lib/cli-engine/cli-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ describe("CLIEngine", () => {
}

// copy into clean area so as not to get "infected" by this project's .eslintrc files
before(() => {
before(function() {

/*
* GitHub Actions Windows and macOS runners occasionally exhibit
* extremely slow filesystem operations, during which copying fixtures
* exceeds the default test timeout, so raise it just for this hook.
* Mocha uses `this` to set timeouts on an individual hook level.
*/
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
shell.mkdir("-p", fixtureDir);
shell.cp("-r", "./tests/fixtures/.", fixtureDir);
});
Expand Down
11 changes: 10 additions & 1 deletion tests/lib/cli-engine/file-enumerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,16 @@ describe("FileEnumerator", () => {
);
}

before(() => {
before(function() {

/*
* GitHub Actions Windows and macOS runners occasionally
* exhibit extremely slow filesystem operations, during which
* copying fixtures exceeds the default test timeout, so raise
* it just for this hook. Mocha uses `this` to set timeouts on
* an individual hook level.
*/
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
fixtureDir = `${os.tmpdir()}/eslint/tests/fixtures/`;
sh.mkdir("-p", fixtureDir);
sh.cp("-r", "./tests/fixtures/*", fixtureDir);
Expand Down
10 changes: 9 additions & 1 deletion tests/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ describe("cli", () => {
}

// copy into clean area so as not to get "infected" by this project's .eslintrc files
before(() => {
before(function() {

/*
* GitHub Actions Windows and macOS runners occasionally exhibit
* extremely slow filesystem operations, during which copying fixtures
* exceeds the default test timeout, so raise it just for this hook.
* Mocha uses `this` to set timeouts on an individual hook level.
*/
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
fixtureDir = `${os.tmpdir()}/eslint/fixtures`;
sh.mkdir("-p", fixtureDir);
sh.cp("-r", "./tests/fixtures/.", fixtureDir);
Expand Down
10 changes: 9 additions & 1 deletion tests/lib/eslint/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ describe("ESLint", () => {
}

// copy into clean area so as not to get "infected" by this project's .eslintrc files
before(() => {
before(function() {

/*
* GitHub Actions Windows and macOS runners occasionally exhibit
* extremely slow filesystem operations, during which copying fixtures
* exceeds the default test timeout, so raise it just for this hook.
* Mocha uses `this` to set timeouts on an individual hook level.
*/
this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
shell.mkdir("-p", fixtureDir);
shell.cp("-r", "./tests/fixtures/.", fixtureDir);
});
Expand Down

0 comments on commit 84fd591

Please # to comment.