( killSignal = '', args = [], readyRegex = /Creating an optimized production/, expectedCode = 0 )
| 53 | } |
| 54 | |
| 55 | const testExitSignal = async ( |
| 56 | killSignal = '', |
| 57 | args = [], |
| 58 | readyRegex = /Creating an optimized production/, |
| 59 | expectedCode = 0 |
| 60 | ) => { |
| 61 | let instance |
| 62 | const killSigint = (inst) => { |
| 63 | instance = inst |
| 64 | } |
| 65 | let output = '' |
| 66 | |
| 67 | let cmdPromise = runNextCommand(args, { |
| 68 | ignoreFail: true, |
| 69 | instance: killSigint, |
| 70 | onStdout: (msg) => { |
| 71 | output += stripAnsi(msg) |
| 72 | }, |
| 73 | }).catch((err) => expect.fail(err.message)) |
| 74 | |
| 75 | await check(() => output, readyRegex) |
| 76 | instance.kill(killSignal) |
| 77 | |
| 78 | const { code, signal } = await cmdPromise |
| 79 | // Node can only partially emulate signals on Windows. Our signal handlers won't affect the exit code. |
| 80 | // See: https://nodejs.org/api/process.html#process_signal_events |
| 81 | const expectedExitSignal = process.platform === `win32` ? killSignal : null |
| 82 | expect(signal).toBe(expectedExitSignal) |
| 83 | expect(code).toBe(expectedCode) |
| 84 | } |
| 85 | |
| 86 | describe('CLI Usage', () => { |
| 87 | ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( |
no test coverage detected