mirror of
https://github.com/gradle/actions.git
synced 2026-03-22 12:05:48 +08:00
The 50ms delay was not sufficient to avoid libuv assertion errors in CI environments. Increasing to 500ms to give pending I/O more time to complete before process.exit() is called. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import {afterEach, describe, expect, it, jest} from '@jest/globals'
|
|
|
|
import {forceExit, getForcedExitDelayMs} from '../../src/force-exit'
|
|
|
|
describe('forceExit', () => {
|
|
afterEach(() => {
|
|
jest.restoreAllMocks()
|
|
jest.useRealTimers()
|
|
})
|
|
|
|
it('adds a short delay on Windows before exiting', async () => {
|
|
jest.useFakeTimers()
|
|
|
|
const exitSpy = jest.spyOn(process, 'exit').mockImplementation((() => undefined) as never)
|
|
|
|
const exitPromise = forceExit('win32')
|
|
await jest.advanceTimersByTimeAsync(499)
|
|
|
|
expect(exitSpy).not.toHaveBeenCalled()
|
|
|
|
await jest.advanceTimersByTimeAsync(1)
|
|
await expect(exitPromise).resolves.toBeUndefined()
|
|
|
|
expect(exitSpy).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
it('exits immediately on non-Windows platforms', async () => {
|
|
const exitSpy = jest.spyOn(process, 'exit').mockImplementation((() => undefined) as never)
|
|
|
|
await expect(forceExit('linux')).resolves.toBeUndefined()
|
|
expect(exitSpy).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
it('only delays on Windows', () => {
|
|
expect(getForcedExitDelayMs('win32')).toBe(500)
|
|
expect(getForcedExitDelayMs('linux')).toBe(0)
|
|
expect(getForcedExitDelayMs('darwin')).toBe(0)
|
|
})
|
|
})
|