test: gate run-node postbuild lock · openclaw/openclaw@ffb83a5
shakkernerd
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1053,39 +1053,50 @@ describe("run-node script", () => {
|
1053 | 1053 | |
1054 | 1054 | let activePostbuilds = 0; |
1055 | 1055 | let maxActivePostbuilds = 0; |
| 1056 | +let markPostbuildStarted!: () => void; |
| 1057 | +let releasePostbuild!: () => void; |
| 1058 | +const postbuildStarted = new Promise<void>((resolve) => { |
| 1059 | +markPostbuildStarted = resolve; |
| 1060 | +}); |
| 1061 | +const postbuildRelease = new Promise<void>((resolve) => { |
| 1062 | +releasePostbuild = resolve; |
| 1063 | +}); |
1056 | 1064 | const runRuntimePostBuild = vi.fn(async () => { |
1057 | 1065 | activePostbuilds += 1; |
1058 | 1066 | maxActivePostbuilds = Math.max(maxActivePostbuilds, activePostbuilds); |
1059 | | -await new Promise((resolve) => setTimeout(resolve, 25)); |
| 1067 | +markPostbuildStarted(); |
| 1068 | +await postbuildRelease; |
1060 | 1069 | activePostbuilds -= 1; |
1061 | 1070 | }); |
1062 | 1071 | const { spawn, spawnSync } = createSpawnRecorder({ |
1063 | 1072 | gitHead: "abc123\n", |
1064 | 1073 | gitStatus: "", |
1065 | 1074 | }); |
1066 | 1075 | |
1067 | | -await expect( |
1068 | | -Promise.all([ |
1069 | | -runStatusCommand({ |
1070 | | - tmp, |
1071 | | - spawn, |
1072 | | - spawnSync, |
1073 | | -env: { |
1074 | | -OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1", |
1075 | | -}, |
1076 | | - runRuntimePostBuild, |
1077 | | -}), |
1078 | | -runStatusCommand({ |
1079 | | - tmp, |
1080 | | - spawn, |
1081 | | - spawnSync, |
1082 | | -env: { |
1083 | | -OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1", |
1084 | | -}, |
1085 | | - runRuntimePostBuild, |
1086 | | -}), |
1087 | | -]), |
1088 | | -).resolves.toEqual([0, 0]); |
| 1076 | +const runs = Promise.all([ |
| 1077 | +runStatusCommand({ |
| 1078 | + tmp, |
| 1079 | + spawn, |
| 1080 | + spawnSync, |
| 1081 | +env: { |
| 1082 | +OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1", |
| 1083 | +}, |
| 1084 | + runRuntimePostBuild, |
| 1085 | +}), |
| 1086 | +runStatusCommand({ |
| 1087 | + tmp, |
| 1088 | + spawn, |
| 1089 | + spawnSync, |
| 1090 | +env: { |
| 1091 | +OPENCLAW_RUN_NODE_BUILD_LOCK_POLL_MS: "1", |
| 1092 | +}, |
| 1093 | + runRuntimePostBuild, |
| 1094 | +}), |
| 1095 | +]); |
| 1096 | + |
| 1097 | +await postbuildStarted; |
| 1098 | +releasePostbuild(); |
| 1099 | +await expect(runs).resolves.toEqual([0, 0]); |
1089 | 1100 | |
1090 | 1101 | expect(runRuntimePostBuild).toHaveBeenCalledTimes(1); |
1091 | 1102 | expect(maxActivePostbuilds).toBe(1); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。