Skip to content

Commit 023dd79

Browse files
committed
test(cli): the probe stubs print with shell builtins, since their PATH holds nothing else
Claude-Session: https://claude.ai/code/session_01SYEJqDL3NXxrJRBVqaMu9T Co-authored-by: Claude <noreply@anthropic.com>
1 parent 28b8d87 commit 023dd79

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/cli/test/doctor-tool-probe-failure.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ function stubDir(label: string, name: string, body: string[], mode = 0o755): str
6565
return dir;
6666
}
6767

68-
/** A stub that writes `text` to stderr and exits `code`. */
68+
/**
69+
* A stub that writes `text` to stderr and exits `code`. Shell builtins only:
70+
* the stub's `PATH` is its own directory, so `cat` and friends are absent.
71+
*/
6972
function failing(text: string, code: number): string[] {
70-
return ["cat >&2 <<'STUB_EOF'", text, 'STUB_EOF', `exit ${code}`];
73+
const quote = (line: string): string => `'${line.replace(/'/g, `'\\''`)}'`;
74+
return [...text.split('\n').map((line) => `printf '%s\\n' ${quote(line)} >&2`), `exit ${code}`];
7175
}
7276

7377
beforeAll(() => {

0 commit comments

Comments
 (0)