This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

Skip Linux-only supervisor tests on non-Linux / missing deps

The systemd and runit installer tests exist to exercise real system
integration, but the two tests fail hard on macOS and on Linux boxes
that dont have runit installed — not because the code is broken,
just because the required binaries arent there. Converted the
runtime-throw (runsvdir case) and the platform-mismatch (systemd
case) into it.skipIf gates so developers on Mac see "skipped"
instead of "runsvdir is not installed" red errors.

CI on Linux still runs both; its where the real validation lives.

Nathan Herald (Apr 24, 2026, 10:53 AM +0200) c4f3451b 5c6dc967

+23 -14
+23 -14
tests/supervisor-service-install.test.ts
··· 9 9 const nodeBin = process.execPath; 10 10 const cliPath = path.join(__dirname, "..", "dist", "cli.js"); 11 11 12 + // Platform gates. Both installers are Linux-only — macOS has no systemd or 13 + // runit. Rather than fail the whole suite on the wrong platform, skip the 14 + // individual tests so developers on Mac see a clean "skipped" rather than 15 + // red "runsvdir is not installed" errors. CI runs on Linux and exercises 16 + // the real code path. 17 + function hasCommand(cmd: string): boolean { 18 + return spawnSync("sh", ["-lc", `command -v ${cmd} >/dev/null 2>&1`]).status === 0; 19 + } 20 + const hasSystemdUser = process.platform === "linux" && hasCommand("systemctl"); 21 + const hasRunit = process.platform === "linux" && hasCommand("runsvdir"); 22 + 12 23 const bgPids: number[] = []; 13 24 const cleanupUnits: string[] = []; 14 25 const cleanupPaths: string[] = []; ··· 39 50 } 40 51 41 52 afterEach(() => { 42 - for (const unit of cleanupUnits.splice(0)) { 43 - spawnSync("systemctl", ["--user", "disable", "--now", unit], { encoding: "utf-8" }); 44 - spawnSync("systemctl", ["--user", "reset-failed", unit], { encoding: "utf-8" }); 45 - const unitPath = path.join(os.homedir(), ".config", "systemd", "user", unit); 46 - try { fs.unlinkSync(unitPath); } catch {} 47 - } 48 - if (cleanupUnits.length > 0) { 53 + // systemctl cleanup is a no-op on macOS where the cmd doesn't exist. 54 + // Guarding saves noisy spawn errors in the test log. 55 + if (hasSystemdUser) { 56 + for (const unit of cleanupUnits.splice(0)) { 57 + spawnSync("systemctl", ["--user", "disable", "--now", unit], { encoding: "utf-8" }); 58 + spawnSync("systemctl", ["--user", "reset-failed", unit], { encoding: "utf-8" }); 59 + const unitPath = path.join(os.homedir(), ".config", "systemd", "user", unit); 60 + try { fs.unlinkSync(unitPath); } catch {} 61 + } 49 62 spawnSync("systemctl", ["--user", "daemon-reload"], { encoding: "utf-8" }); 50 63 } else { 51 - spawnSync("systemctl", ["--user", "daemon-reload"], { encoding: "utf-8" }); 64 + cleanupUnits.length = 0; 52 65 } 53 66 54 67 for (const pid of bgPids.splice(0)) killPid(pid); ··· 58 71 }); 59 72 60 73 describe("supervisor service installers", () => { 61 - it("installs and uninstalls a user systemd service", async () => { 74 + it.skipIf(!hasSystemdUser)("installs and uninstalls a user systemd service", async () => { 62 75 const sessionDir = fs.mkdtempSync(path.join(os.tmpdir(), "pty-systemd-")); 63 76 cleanupPaths.push(sessionDir); 64 77 ··· 90 103 expect(activeAfter.status).not.toBe(0); 91 104 }, 30000); 92 105 93 - it("installs a runit service that can be started by a private runsvdir", async () => { 94 - if (spawnSync("sh", ["-lc", "command -v runsvdir >/dev/null 2>&1"]).status !== 0) { 95 - throw new Error("runsvdir is not installed"); 96 - } 97 - 106 + it.skipIf(!hasRunit)("installs a runit service that can be started by a private runsvdir", async () => { 98 107 const root = fs.mkdtempSync(path.join(os.tmpdir(), "pty-runit-")); 99 108 const sessionDir = path.join(root, "sessions"); 100 109 const svDir = path.join(root, "sv");