mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-09 06:28:59 +02:00
test: stdin EPIPE observation is scheduling-dependent under shard load; pin the invariant instead
A delivered answer is never reclassified as a spawn error; when the EPIPE is observed it is reported as stdinError. Whether it is observed before the child's exit resolves the call is not something the test can force. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
05d12bef01
commit
93769d2c9b
@@ -627,13 +627,16 @@ describe('runExternal (spawn-bin)', () => {
|
||||
const survivors = spawnSync('sh', ['-c', `ps -eo args | grep '^sleep 21.${nonce}$' || true`], { encoding: 'utf8', timeout: 10_000 }).stdout.trim();
|
||||
expect(survivors).toBe('');
|
||||
});
|
||||
test('a child that closes its stdin without reading reports stdinError separately from error; the answer survives', async () => {
|
||||
// the child closes its read end first and stays alive long enough for the write to hit it,
|
||||
// so the EPIPE is deterministic (a child that merely exits fast races the write under load)
|
||||
test('a child that closes its stdin without reading: the answer survives and a stdin write error never becomes `error`', async () => {
|
||||
// The child closes its read end first and stays alive so the write hits a closed pipe.
|
||||
// Whether the EPIPE is observed before the child's exit resolves the call depends on
|
||||
// scheduling under load (the full suite runs six shards at once), so the invariant
|
||||
// pinned here is the one the hook relies on: a delivered answer is never reclassified.
|
||||
const r = await runExternal('sh', ['-c', 'exec 0<&-; echo answered; sleep 0.3; exit 0'], { timeoutMs: 5000, input: Buffer.alloc(1_000_000, 0x78) });
|
||||
expect(r.status).toBe(0);
|
||||
expect(r.error).toBeUndefined();
|
||||
expect(r.stdinError).toBe('EPIPE');
|
||||
expect(r.timedOut).toBe(false);
|
||||
if (r.stdinError !== undefined) expect(r.stdinError).toBe('EPIPE');
|
||||
expect(r.stdout.toString()).toBe('answered\n');
|
||||
});
|
||||
test('an unspawnable command resolves with an error code and null status', async () => {
|
||||
|
||||
Reference in New Issue
Block a user