Skip to content
Permalink
Browse files

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.
  • Loading branch information
btmills committed Oct 20, 2020
1 parent 1faeb84 commit 84fd591c234accc41bb5af555f178825012fd35d
Showing with 37 additions and 4 deletions.
  1. +9 −1 tests/lib/cli-engine/cli-engine.js
  2. +10 −1 tests/lib/cli-engine/file-enumerator.js
  3. +9 −1 tests/lib/cli.js
  4. +9 −1 tests/lib/eslint/eslint.js
@@ -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);
});
@@ -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);
@@ -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);
@@ -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);
});

0 comments on commit 84fd591

Please sign in to comment.
You can’t perform that action at this time.