Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apps/host-daemon/src/environment-lifecycle-script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ afterEach(async () => {
});

describe("core environment scripts", () => {
it.each(["setup", "teardown"] as const)(
"supplies stdin EOF so %s continues to completion",
async (kind) => {
const workspacePath = await workspace(
kind,
'cat >/dev/null\nprintf complete > marker\nprintf "\\342"\nsleep 0.05\nprintf "\\234\\223\\n"\nprintf "done\\n" >&2\n',
);
const output: string[] = [];
const run = kind === "setup" ? runSetupScript : runTeardownScript;
const result = await run({
workspacePath,
timeoutMs: 1000,
env: { PATH: "/usr/bin:/bin" },
onProgress: (entry) => output.push(entry.text),
});
expect(result).toMatchObject({ ran: true, exitCode: 0 });
expect(await readFile(join(workspacePath, "marker"), "utf8")).toBe(
"complete",
);
expect(output).toContain("✓");
expect(output).toContain("done");
expect(result.output).toContain("✓\n");
},
);

it("runs in the environment directory and streams stdout and stderr", async () => {
const workspacePath = await workspace(
"setup",
Expand Down
4 changes: 2 additions & 2 deletions apps/host-daemon/src/environment-lifecycle-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { HostDaemonContributedEnvEntry } from "@bb/host-daemon-contract";
import {
isProcessGroupAlive,
killProcessGroup,
spawnPortablePipedProcess,
spawnPortableOutputProcess,
supportsProcessGroups,
} from "@bb/process-utils";
import fs from "node:fs/promises";
Expand Down Expand Up @@ -133,7 +133,7 @@ async function runLifecycleScript(
},
true,
);
const child = spawnPortablePipedProcess({
const child = spawnPortableOutputProcess({
command: command.command,
args: command.args,
cwd: args.workspacePath,
Expand Down
Loading