Skip to content

Commit 6085111

Browse files
test: stand in for process.exitCode in the agreement sweep under Bun
Bun's sandboxed process.exitCode accessor drops writes, so the test read undefined where the sweep set 0.
1 parent 533005b commit 6085111

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎test/unitCases/tooling/compare-agreement.unittest.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,18 @@ jest.mock("../../../tooling/compare-tools-harness", () => ({
1919
const sweep = async (script, fixture) => {
2020
const previous = {
2121
RELATION: process.env.RELATION,
22-
FIXTURE: process.env.FIXTURE,
23-
exitCode: process.exitCode
22+
FIXTURE: process.env.FIXTURE
2423
};
24+
// WHY: Bun's sandboxed `process.exitCode` accessor drops every write, so a
25+
// plain property stands in for it while the sweep runs.
26+
const exitCodeDescriptor = /** @type {PropertyDescriptor} */ (
27+
Object.getOwnPropertyDescriptor(process, "exitCode")
28+
);
29+
Object.defineProperty(process, "exitCode", {
30+
value: undefined,
31+
writable: true,
32+
configurable: true
33+
});
2534
process.env.RELATION = "agreement";
2635
process.env.FIXTURE = fixture;
2736
/** @type {string[]} */
@@ -50,7 +59,7 @@ const sweep = async (script, fixture) => {
5059
if (previous[key] === undefined) delete process.env[key];
5160
else process.env[key] = previous[key];
5261
}
53-
process.exitCode = previous.exitCode;
62+
Object.defineProperty(process, "exitCode", exitCodeDescriptor);
5463
}
5564
};
5665

0 commit comments

Comments
 (0)