Skip to content

Commit 5f652de

Browse files
committed
fix portable packaging and smoke timeout cleanup
1 parent 4060abb commit 5f652de

2 files changed

Lines changed: 48 additions & 24 deletions

File tree

packaging.test.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ Deno.test({
8888

8989
const tempDir = await Deno.makeTempDir();
9090
try {
91+
let optionalOpenCodePath: string | undefined;
92+
try {
93+
optionalOpenCodePath = Deno.env.get("OPENCODE_BIN") ?? undefined;
94+
} catch {
95+
optionalOpenCodePath = undefined;
96+
}
97+
9198
const esmRunnerPath = join(tempDir, "load-esm.mjs");
9299
const bunRunnerPath = join(tempDir, "load-bun.mjs");
93100
const esmEntrypoint =
@@ -124,30 +131,34 @@ Deno.test({
124131
assertEquals(bunLoad.stdout.trim(), '["graphiti"]');
125132
}
126133

127-
const localOpenCodePath = "/Users/vicary/.opencode/bin/opencode";
128-
try {
129-
const opencodeInfo = await Deno.stat(localOpenCodePath);
130-
if (opencodeInfo.isFile) {
131-
const isolatedOpenCode = await new Deno.Command(localOpenCodePath, {
132-
args: ["--print-logs", "stats"],
133-
cwd: workspacePath,
134-
env: {
135-
HOME: isolatedHome,
136-
XDG_CONFIG_HOME: join(isolatedHome, ".config"),
137-
},
138-
stdout: "piped",
139-
stderr: "piped",
140-
}).output();
141-
const isolatedOpenCodeOutput = decodeText(isolatedOpenCode.stdout) +
142-
decodeText(isolatedOpenCode.stderr);
143-
assertEquals(
144-
isolatedOpenCodeOutput.includes("Missing 'default' export"),
145-
false,
146-
isolatedOpenCodeOutput,
147-
);
134+
if (optionalOpenCodePath) {
135+
try {
136+
const opencodeInfo = await Deno.stat(optionalOpenCodePath);
137+
if (opencodeInfo.isFile) {
138+
const isolatedOpenCode = await new Deno.Command(
139+
optionalOpenCodePath,
140+
{
141+
args: ["--print-logs", "stats"],
142+
cwd: workspacePath,
143+
env: {
144+
HOME: isolatedHome,
145+
XDG_CONFIG_HOME: join(isolatedHome, ".config"),
146+
},
147+
stdout: "piped",
148+
stderr: "piped",
149+
},
150+
).output();
151+
const isolatedOpenCodeOutput = decodeText(isolatedOpenCode.stdout) +
152+
decodeText(isolatedOpenCode.stderr);
153+
assertEquals(
154+
isolatedOpenCodeOutput.includes("Missing 'default' export"),
155+
false,
156+
isolatedOpenCodeOutput,
157+
);
158+
}
159+
} catch {
160+
// OPENCODE_BIN is optional; keep the portable package checks above.
148161
}
149-
} catch {
150-
// OpenCode is not available in CI; keep the portable package checks above.
151162
}
152163
} finally {
153164
await Deno.remove(tempDir, { recursive: true }).catch(() => undefined);

src/services/runtime-teardown.smoke.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const waitForText = async (
4545
stream: ReadableStream<Uint8Array> | null,
4646
expected: string,
4747
timeoutMs: number,
48+
onTimeout?: () => void,
4849
): Promise<{
4950
seen: string;
5051
remainder: Promise<string>;
@@ -69,6 +70,7 @@ const waitForText = async (
6970
})(),
7071
new Promise<never>((_, reject) => {
7172
timeoutId = setTimeout(() => {
73+
onTimeout?.();
7274
void reader.cancel();
7375
reject(
7476
new Error(`timed out waiting for ${JSON.stringify(expected)}`),
@@ -115,7 +117,18 @@ Deno.test({
115117
stderr: "piped",
116118
}).spawn();
117119

118-
const stdoutState = await waitForText(child.stdout, "ready\n", 2_000);
120+
const stdoutState = await waitForText(
121+
child.stdout,
122+
"ready\n",
123+
2_000,
124+
() => {
125+
try {
126+
child.kill("SIGKILL");
127+
} catch {
128+
// Best-effort cleanup only.
129+
}
130+
},
131+
);
119132
const stderrPromise = new Response(child.stderr).text();
120133

121134
child.kill("SIGINT");

0 commit comments

Comments
 (0)