mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-02 17:40:02 +02:00
test(qa-deadline): never attach a reader to the full-pipe fixture's stdout
The full-pipe receipt test attached a 'data' listener (flowing mode) and then paused; on CI the reader could drain the 2 MB write before the pause, so the receipt write never blocked and the helper exited 0 in ~126 ms. The stdout pipe now stays unread until the assertion, which is what the test means to model.
This commit is contained in:
1 parent
07b21ea133
commit
4643cb8550
1 file changed
+3
-4
@@ -52,10 +52,10 @@ function receipt(output: string) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function background(args: string[], preload?: string) {
|
||||
function background(args: string[], preload?: string, options: { unreadStdout?: boolean } = {}) {
|
||||
const child = spawn(process.execPath, [...(preload ? ['--preload', preload] : []), CLI, ...args], { stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
let stdout = '', stderr = '';
|
||||
child.stdout!.on('data', chunk => { stdout += chunk; });
|
||||
if (!options.unreadStdout) child.stdout!.on('data', chunk => { stdout += chunk; });
|
||||
child.stderr!.on('data', chunk => { stderr += chunk; });
|
||||
const result = new Promise<{ code: number | null; signal: NodeJS.Signals | null; stdout: string; stderr: string }>((resolve, reject) => {
|
||||
child.once('error', reject);
|
||||
@@ -345,8 +345,7 @@ import { write } from 'node:fs';
|
||||
write(1, Buffer.alloc(2 * 1024 * 1024, 32), () => {});
|
||||
await Bun.sleep(100);
|
||||
`);
|
||||
const runner = background(['start', f.receipt, '30'], preload);
|
||||
runner.child.stdout!.pause();
|
||||
const runner = background(['start', f.receipt, '30'], preload, { unreadStdout: true });
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
try {
|
||||
const code = await Promise.race([
|
||||
|
||||
Reference in new issue
Block a user