test(process): isolate child startup and assert cleanup recovery values

This commit is contained in:
morluto
2026-10-23 04:29:25 +08:00
parent 746a41937d
commit 3e87889bfb
2 changed files with 13 additions and 5 deletions
+10 -2
View File
@@ -274,7 +274,11 @@ it("resolves an artifact cleanup error when its scope owner later closes", async
ok(await resources.read("fixture", 1)),
);
expect(retried.ok).toBe(true);
if (!retried.ok) throw retried.error;
expect(retried.value).toEqual({
bytes: Buffer.alloc(0),
sha256: "0".repeat(64),
});
expect(first.error.cleanupIncomplete).toBe(false);
expect(closes).toBe(2);
await resources.close();
@@ -350,7 +354,11 @@ it("keeps a runtime root until its descriptor cleanup owner is released", async
const retried = await resources.run(async () =>
ok(await resources.read("fixture", 1)),
);
expect(retried.ok).toBe(true);
if (!retried.ok) throw retried.error;
expect(retried.value).toEqual({
bytes: Buffer.alloc(0),
sha256: "0".repeat(64),
});
expect(first.error.cleanupIncomplete).toBe(false);
await resources.release();
expect(rootCloses).toBe(1);
+3 -3
View File
@@ -10,7 +10,7 @@ describe("execFileBoundedOutput", () => {
"-e",
"process.stdout.write('x'.repeat(70000)); process.stderr.write('failure detail');",
],
{ env: process.env, limit: 64 * 1024 },
{ env: {}, limit: 64 * 1024 },
);
expect(result.exitCode).toBe(0);
expect(Buffer.byteLength(result.stdout)).toBeLessThan(64 * 1024 + 50);
@@ -26,7 +26,7 @@ describe("execFileBoundedOutput", () => {
"-e",
"process.stdout.write('x'.repeat(70000)); process.stderr.write('package conflict'); process.exitCode = 1;",
],
{ env: process.env, limit: 64 * 1024 },
{ env: {}, limit: 64 * 1024 },
);
expect(result.exitCode).toBe(1);
expect(result.stderr).toBe("package conflict");
@@ -40,7 +40,7 @@ describe("execFileBoundedOutput", () => {
"-e",
"process.stderr.write('warning '.repeat(10000)); process.stderr.write('error: final conflict'); process.exitCode = 1;",
],
{ env: process.env, limit: 64 * 1024 },
{ env: {}, limit: 64 * 1024 },
);
expect(result.exitCode).toBe(1);
expect(result.stderr).toContain("[output omitted]");