Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test(env-path): accept any non-zero exit for the unread background job (#6556)

Milind Soni6e1ffa6480d6
diff --git a/server/env-path.test.ts b/server/env-path.test.ts
index ab27d7a284..fed156adec 100644
--- a/server/env-path.test.ts
+++ b/server/env-path.test.ts
@@ -270,7 +270,7 @@ describe("augmentedPath", () => {
const jobStatus = join(homedir(), "late-job.status");
writeFileSync(
shell,
- `#!/bin/sh\nprintf '__OMB_PATH__%s__OMB_END__' '${rcOnlyBin}'\n(head -c 200000 /dev/zero; echo $? > '${jobStatus}') &\n`,
+ `#!/bin/sh\nprintf '__OMB_PATH__%s__OMB_END__' '${rcOnlyBin}'\n(head -c 800000 /dev/zero; echo $? > '${jobStatus}') &\n`,
);
chmodSync(shell, 0o755);
@@ -282,8 +282,9 @@ describe("augmentedPath", () => {
augmentedPath();
await vi.waitFor(() => expect(augmentedPath().split(delimiter)).toContain(rcOnlyBin));
- // 141 = 128 + SIGPIPE: the job's write hit a pipe nobody reads any more (0 would mean it was all read).
- await vi.waitFor(() => expect(existsSync(jobStatus) && readFileSync(jobStatus, "utf8").trim()).toBe("141"), {
+ // A write nobody reads any more ends the job by SIGPIPE (141) on macOS and can fail with an error (1) on Linux;
+ // 0 would mean it was all read.
+ await vi.waitFor(() => expect(existsSync(jobStatus) && readFileSync(jobStatus, "utf8").trim()).toMatch(/^[1-9]\d*$/), {
timeout: 5000,
});
expect(augmentedPath().split(delimiter)).toContain(rcOnlyBin);