Skip to content

Commit dfecef5

Browse files
committed
test(hooks): accept the timed-out PowerShell outcome
runHook has three outcomes for the PowerShell case: pwsh ran, pwsh is not installed, or pwsh was still starting when the hook budget expired. The assertion covered only the first two, so a saturated CI runner failed here with a bare "expected false to be true" that named nothing. The timeout path returns allow with empty stdout and stderr, so neither branch matched. All three outcomes confirm the PowerShell spawn path was taken, which is what the test is for.
1 parent 6b14a98 commit dfecef5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/agent-core/test/hooks/runner.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,20 @@ describe('runHook process runner', () => {
143143
// PowerShell cold start can exceed several seconds on a loaded CI runner, so the
144144
// hook budget and the surrounding test timeout both need headroom above it, and the
145145
// test timeout must stay above the hook budget so the hook result is what gets asserted.
146+
//
147+
// Three outcomes all confirm the PowerShell path was taken: pwsh ran, pwsh is not
148+
// installed, or pwsh was still starting when the hook budget expired. The last one is
149+
// what `runHook` returns as `allow` with empty streams and `timedOut`, and leaving it
150+
// out made a saturated runner fail here with a bare "expected false to be true".
146151
it('uses a non-interactive PowerShell process when requested', async () => {
147152
const runHook = await importRunHook();
148153
const result = await runHook(`Write-Output 'ok'`, {}, { timeout: 15, shell: 'powershell' });
149154

150155
expect(result.action).toBe('allow');
151156
expect(
152-
result.stdout?.trim() === 'ok' || result.stderr?.includes('ENOENT') === true,
157+
result.stdout?.trim() === 'ok' ||
158+
result.stderr?.includes('ENOENT') === true ||
159+
result.timedOut === true,
153160
).toBe(true);
154161
}, 30_000);
155162
});

0 commit comments

Comments
 (0)