Files
nextcraft/apps/cli/tests/spawn.test.ts
T
CIAgent 1a88ab3199
Release / release (push) Successful in 3m45s
CI / python (push) Successful in 1m52s
CI / node (push) Successful in 1m0s
merge: milestone/v0.8-ship-anywhere -> main (v0.8 complete — Ship Anywhere)
The v0.8 milestone: installable on any Debian-based server via docker
(Gitea registry image, honest sandbox degrade), deb (amd64+arm64,
advisory postinst), and arch-aware binary — with release consistency
enforced by pre-commit hooks + Gitea Actions (3-runner fleet on CT 113,
machine-made releases with the full 8-asset matrix + registry image), the
CLI carrying the full suite (guide, channel-aware doctor), and the admin
runbook (deploy/README.md, evidence-backed recipes).

---ci---
phase: 6
milestone: v0.8
status: complete
requirements:
  covered: [REQ-8-001, REQ-8-002, REQ-8-003, REQ-8-004, REQ-8-005]
  partial: []
---/ci---
2026-09-29 16:04:40 +00:00

32 lines
1.0 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { run } from "../src/lib/spawn.ts";
test("spawn: returns exit code of short process", async () => {
const res = await run("node", ["-e", "process.exit(3)"], { capture: true, timeoutMs: 5000 });
assert.equal(res.code, 3);
assert.equal(res.timedOut, false);
});
test("spawn: timeout kills and reports timedOut", async () => {
const res = await run("node", ["-e", "setTimeout(() => {}, 10000)"], {
capture: true,
timeoutMs: 300,
});
assert.equal(res.timedOut, true);
assert.ok(res.code !== 0);
});
test("spawn: missing binary resolves code 127, never rejects", async () => {
const res = await run("definitely-not-a-real-binary-xyz", [], { capture: true, timeoutMs: 1000 });
assert.equal(res.code, 127);
});
test("spawn: capture collects stdout", async () => {
const res = await run("node", ["-e", "process.stdout.write('hello')"], {
capture: true,
timeoutMs: 5000,
});
assert.equal(res.stdout, "hello");
});