test: allow headroom for shell fixture subprocesses

This commit is contained in:
gitea committed 2026-10-20 23:00:39 +08:00
1 parent fac81b08e8
commit 48ab35a8ac
2 files changed
+21 -19

No files matched your search

+8 -7
View File
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { spawnSync } from "node:child_process";
// Shell fixtures start several processes; allow headroom on a busy host.
const fixtures: string[] = [];
afterEach(() => { for (const root of fixtures.splice(0)) rmSync(root, { recursive: true, force: true }); });
const hash = (data: Buffer | string) => createHash("sha256").update(data).digest("hex");
@@ -63,7 +64,7 @@ if [ -n "$dest" ]; then cp "$file" "$dest"; else cat "$file"; fi
const run = (env: Record<string, string> = {}) => spawnSync("bash", [resolve(import.meta.dir, "install.sh")], {
cwd: root,
env: { ...process.env, PATH: `${tools}:${process.env.PATH}`, HOSE_USE_INSTALL_DIR: target, HOSE_USE_VERSION: "9.9.9", HOSE_USE_MIRROR: "auto", HOSE_FIXTURE_SOURCE: source, HOSE_FIXTURE_LOG: join(root, "skill.log"), HOSE_FIXTURE_REQUESTS: join(root, "requests.log"), ...env },
encoding: "utf8", timeout: 10_000,
encoding: "utf8", timeout: 30_000,
});
return { root, source, target, run, binary };
}
@@ -77,7 +78,7 @@ describe("verified standalone installer", () => {
expect(readlinkSync(join(f.target, "hose-aipro"))).toBe("hose-use");
expect(readFileSync(join(f.root, "skill.log"), "utf8").trim()).toBe("skill install --yes");
expect(readdirSync(f.target).sort()).toEqual(["hose-aipro", "hose-use"]);
});
}, 60_000);
for (const options of [{ badHash: true }, { missingEntry: true }, { duplicate: true }]) {
test(`rejects an invalid manifest/archive and preserves the old binary: ${JSON.stringify(options)}`, () => {
@@ -89,7 +90,7 @@ describe("verified standalone installer", () => {
expect(result.status).toBe(1);
expect(readFileSync(join(f.target, "hose-use"), "utf8")).toBe("old binary");
expect(existsSync(join(f.root, "skill.log"))).toBe(false);
});
}, 60_000);
}
test("does not silently bypass missing checksums or guess an old tag", () => {
@@ -100,7 +101,7 @@ describe("verified standalone installer", () => {
expect(unknown.stderr).toContain("could not resolve");
expect(existsSync(join(f.target, "hose-use"))).toBe(false);
expect(readFileSync(join(f.root, "requests.log"), "utf8")).not.toContain("v0.8.9");
});
}, 60_000);
test("uses a verified raw fallback and a fixed tag when the first mirror fails", () => {
const f = fixture({ rawOnly: true });
@@ -110,7 +111,7 @@ describe("verified standalone installer", () => {
const requests = readFileSync(join(f.root, "requests.log"), "utf8");
expect(requests).toContain("/download/v9.9.9/");
expect(requests).not.toContain("/latest/download/");
});
}, 60_000);
test("reports Skill failure without claiming it was installed", () => {
const f = fixture();
@@ -119,7 +120,7 @@ describe("verified standalone installer", () => {
expect(result.stderr).toContain("binary installed");
expect(result.stdout).not.toContain("Agent skill installed");
expect(result.stdout).not.toContain("successfully installed");
});
}, 60_000);
test("does not replace directories or follow an existing alias into a directory", () => {
const f = fixture();
@@ -133,5 +134,5 @@ describe("verified standalone installer", () => {
writeFileSync(join(f.target, "hose-use"), "old binary");
expect(f.run().status).toBe(1);
expect(readFileSync(join(f.target, "hose-use"), "utf8")).toBe("old binary");
});
}, 60_000);
});