fix(e2e): reach child quiescence before temp-dir cleanup in built-bin smokes
The acp built-bin smoke killed its child and immediately rm'd the temp consumer dir; POSIX tolerates unlinking a live process's cwd, Windows fails EBUSY while the child still holds its cwd and session-log handles (the CI windows job's only red step). Await the child's exit after SIGKILL and give both smokes' rm a brief retry for the OS handle-release lag.
This commit is contained in:
@@ -95,8 +95,19 @@ let consumer: string | undefined
|
|||||||
let child: ReturnType<typeof spawn> | undefined
|
let child: ReturnType<typeof spawn> | undefined
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
if (child !== undefined) { child.kill('SIGKILL'); child = undefined }
|
if (child !== undefined) {
|
||||||
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true })
|
const proc = child
|
||||||
|
child = undefined
|
||||||
|
// Windows retains the child's cwd and session-log handles until process
|
||||||
|
// teardown completes, so await exit before removing the temp directory.
|
||||||
|
if (proc.exitCode === null && proc.signalCode === null) {
|
||||||
|
const exited = new Promise<void>((resolve) => { proc.once('exit', () => { resolve() }) })
|
||||||
|
proc.kill('SIGKILL')
|
||||||
|
await exited
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Windows can briefly retain released handles after exit; retry removal.
|
||||||
|
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })
|
||||||
consumer = undefined
|
consumer = undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ function runBuiltBin(cwd: string, configArg: string, line: string): Promise<{ st
|
|||||||
let consumer: string | undefined
|
let consumer: string | undefined
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true })
|
// Windows can briefly retain released handles after exit; retry removal.
|
||||||
|
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })
|
||||||
consumer = undefined
|
consumer = undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user