From cec3b87de530a098f0875f2f0335e0a73ff240de Mon Sep 17 00:00:00 2001 From: Justin Lee Date: Mon, 17 Aug 2026 17:33:40 +0800 Subject: [PATCH] test(herdr): make the Quick Start close test's pty wrapper work on Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BSD script (macOS) takes the command as positional args after the file; util-linux script (ubuntu CI) rejects positional commands and needs -c, so the onboarding process never launched on CI and the marker never appeared — a deterministic LINGERED on both Node jobs. Branch on platform: `script -qec "" /dev/null` on Linux, the BSD form elsewhere. Also redirect the background job as a whole: the feeder subshell's inherited stderr held spawnSync's pipe open until its sleep ended, so even a passing run ate the full 30s timeout (now ~250ms), and the sleep shrinks from 40s to 12s — still well past the 8s poll window. Co-Authored-By: Claude Fable 5 --- test/herdr-plugin.test.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/herdr-plugin.test.js b/test/herdr-plugin.test.js index a6e76fcb..39f1eaa1 100644 --- a/test/herdr-plugin.test.js +++ b/test/herdr-plugin.test.js @@ -1016,10 +1016,17 @@ describe('Herdr Quick Start close', () => { // stdin is held open far longer than the poll window on purpose: otherwise // the process would exit on stdin EOF and the test would pass for the wrong // reason. Seeing the marker inside the window means `q` itself ended it. - const command = `( printf 'q'; sleep 40 ) | script -q /dev/null ` - + `env CCXRAY_HOME=${JSON.stringify(home)} HERDR_CONFIG_PATH=${JSON.stringify(cfg)} ` + // BSD script (macOS) takes the command as positional args after the file; + // util-linux script (Linux CI) rejects positional commands and needs -c. + const run = `env CCXRAY_HOME=${JSON.stringify(home)} HERDR_CONFIG_PATH=${JSON.stringify(cfg)} ` + `CCXRAY_PRICING_CACHE=/nonexistent/p.json HERDR_PANE_ID= ` - + `/bin/sh -c ${JSON.stringify(inner)} >/dev/null 2>&1 &\n` + + `/bin/sh -c ${JSON.stringify(inner)}`; + const pty = process.platform === 'linux' + ? `script -qec ${JSON.stringify(run)} /dev/null` + : `script -q /dev/null ${run}`; + // The job-level redirect covers the feeder subshell too — its inherited + // stderr would otherwise hold spawnSync's pipe open until the sleep ends. + const command = `{ ( printf 'q'; sleep 12 ) | ${pty}; } >/dev/null 2>&1 &\n` + `for i in $(seq 1 40); do [ -f ${JSON.stringify(marker)} ] && break; sleep 0.2; done\n` + `[ -f ${JSON.stringify(marker)} ] && echo EXITED || echo LINGERED\n` + `pkill -f ${JSON.stringify(onboarding)} 2>/dev/null; true`;