From 84fd591c234accc41bb5af555f178825012fd35d Mon Sep 17 00:00:00 2001 From: Brandon Mills Date: Tue, 20 Oct 2020 09:04:17 -0400 Subject: [PATCH] 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. --- tests/lib/cli-engine/cli-engine.js | 10 +++++++++- tests/lib/cli-engine/file-enumerator.js | 11 ++++++++++- tests/lib/cli.js | 10 +++++++++- tests/lib/eslint/eslint.js | 10 +++++++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/lib/cli-engine/cli-engine.js b/tests/lib/cli-engine/cli-engine.js index b215b0d315b..b4d65fa1163 100644 --- a/tests/lib/cli-engine/cli-engine.js +++ b/tests/lib/cli-engine/cli-engine.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); }); diff --git a/tests/lib/cli-engine/file-enumerator.js b/tests/lib/cli-engine/file-enumerator.js index 43728862d95..7f91b2a95f4 100644 --- a/tests/lib/cli-engine/file-enumerator.js +++ b/tests/lib/cli-engine/file-enumerator.js @@ -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); diff --git a/tests/lib/cli.js b/tests/lib/cli.js index a1d9a23e491..0f8a24c2e28 100644 --- a/tests/lib/cli.js +++ b/tests/lib/cli.js @@ -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); diff --git a/tests/lib/eslint/eslint.js b/tests/lib/eslint/eslint.js index dbb0059286c..d6abf5a8bda 100644 --- a/tests/lib/eslint/eslint.js +++ b/tests/lib/eslint/eslint.js @@ -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); });