Fix tests exit race condition (#60757)
This ensures we don't allow a following exit condition to override a previous as async work is done before the `process.exit` actually occurs so a follow-up one could override the first giving a false negative. Closes NEXT-1911
This commit is contained in:
parent
a211566655
commit
72e381c8b0
1 changed files with 9 additions and 5 deletions
14
run-tests.js
14
run-tests.js
|
@ -124,7 +124,15 @@ ${output}
|
|||
}
|
||||
}
|
||||
|
||||
let exiting = false
|
||||
|
||||
const cleanUpAndExit = async (code) => {
|
||||
if (exiting) {
|
||||
return
|
||||
}
|
||||
exiting = true
|
||||
console.log(`exiting with code ${code}`)
|
||||
|
||||
if (process.env.NEXT_TEST_STARTER) {
|
||||
await fsp.rm(process.env.NEXT_TEST_STARTER, {
|
||||
recursive: true,
|
||||
|
@ -140,11 +148,7 @@ const cleanUpAndExit = async (code) => {
|
|||
if (process.env.CI) {
|
||||
await maybeLogSummary()
|
||||
}
|
||||
console.log(`exiting with code ${code}`)
|
||||
|
||||
setTimeout(() => {
|
||||
process.exit(code)
|
||||
}, 1)
|
||||
process.exit(code)
|
||||
}
|
||||
|
||||
const isMatchingPattern = (pattern, file) => {
|
||||
|
|
Loading…
Reference in a new issue