mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 07:20:43 +00:00
test: gate run-node postbuild lock
This commit is contained in:
@@ -1053,10 +1053,19 @@ describe("run-node script", () => {
|
||||
|
||||
let activePostbuilds = 0;
|
||||
let maxActivePostbuilds = 0;
|
||||
let markPostbuildStarted!: () => void;
|
||||
let releasePostbuild!: () => void;
|
||||
const postbuildStarted = new Promise<void>((resolve) => {
|
||||
markPostbuildStarted = resolve;
|
||||
});
|
||||
const postbuildRelease = new Promise<void>((resolve) => {
|
||||
releasePostbuild = resolve;
|
||||
});
|
||||
const runRuntimePostBuild = vi.fn(async () => {
|
||||
activePostbuilds += 1;
|
||||
maxActivePostbuilds = Math.max(maxActivePostbuilds, activePostbuilds);
|
||||
await new Promise((resolve) => setTimeout(resolve, 25));
|
||||
markPostbuildStarted();
|
||||
await postbuildRelease;
|
||||
activePostbuilds -= 1;
|
||||
});
|
||||
const { spawn, spawnSync } = createSpawnRecorder({
|
||||
@@ -1064,28 +1073,30 @@ describe("run-node script", () => {
|
||||
gitStatus: "",
|
||||
});
|
||||
|
||||
await expect(
|
||||
Promise.all([
|
||||
runStatusCommand({
|
||||
tmp,
|
||||
spawn,
|
||||
spawnSync,
|
||||
env: {
|
||||
OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1",
|
||||
},
|
||||
runRuntimePostBuild,
|
||||
}),
|
||||
runStatusCommand({
|
||||
tmp,
|
||||
spawn,
|
||||
spawnSync,
|
||||
env: {
|
||||
OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1",
|
||||
},
|
||||
runRuntimePostBuild,
|
||||
}),
|
||||
]),
|
||||
).resolves.toEqual([0, 0]);
|
||||
const runs = Promise.all([
|
||||
runStatusCommand({
|
||||
tmp,
|
||||
spawn,
|
||||
spawnSync,
|
||||
env: {
|
||||
OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1",
|
||||
},
|
||||
runRuntimePostBuild,
|
||||
}),
|
||||
runStatusCommand({
|
||||
tmp,
|
||||
spawn,
|
||||
spawnSync,
|
||||
env: {
|
||||
OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1",
|
||||
},
|
||||
runRuntimePostBuild,
|
||||
}),
|
||||
]);
|
||||
|
||||
await postbuildStarted;
|
||||
releasePostbuild();
|
||||
await expect(runs).resolves.toEqual([0, 0]);
|
||||
|
||||
expect(runRuntimePostBuild).toHaveBeenCalledTimes(1);
|
||||
expect(maxActivePostbuilds).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user