From 295f15e057dbf03e05634e06baaa2a99c718b1ce Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 16 Nov 2022 13:16:35 -0800 Subject: [PATCH] Fix test retry cleanup (#43011) As noticed in https://github.com/vercel/next.js/pull/42966#pullrequestreview-1181705091 we weren't resetting tests correctly on retry causing an incorrect pass. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) --- run-tests.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/run-tests.js b/run-tests.js index 18d93fbadad7..f82c2eed6066 100644 --- a/run-tests.js +++ b/run-tests.js @@ -356,7 +356,13 @@ async function main() { } catch (err) { if (i < numRetries) { try { - const testDir = path.dirname(path.join(__dirname, test)) + let testDir = path.dirname(path.join(__dirname, test)) + + // if test is nested in a test folder traverse up a dir to ensure + // we clean up relevant test files + if (testDir.endsWith('/test') || testDir.endsWith('\\test')) { + testDir = path.join(testDir, '../') + } console.log('Cleaning test files at', testDir) await exec(`git clean -fdx "${testDir}"`) await exec(`git checkout "${testDir}"`)