Skip to content

Commit 280e8d4

Browse files
authored
test: accelerate package candidate safety proofs (#100008)
1 parent 6169e5d commit 280e8d4

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

test/scripts/resolve-openclaw-package-candidate.test.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,28 @@ describe("resolve-openclaw-package-candidate", () => {
219219
["--package-sha256", [...requiredArgs, "--package-sha256", "", "--package-sha256", "abc123"]],
220220
[
221221
"--source",
222-
["--source", "npm", "--source", "artifact", "--output-dir", ".artifacts/docker-e2e-package"],
222+
[
223+
"--source",
224+
"npm",
225+
"--source",
226+
"artifact",
227+
"--output-dir",
228+
".artifacts/docker-e2e-package",
229+
],
223230
],
224231
[
225232
"--trusted-source-id",
226233
[...requiredArgs, "--trusted-source-id", "one", "--trusted-source-id", "two"],
227234
],
228235
[
229236
"--trusted-source-policy",
230-
[...requiredArgs, "--trusted-source-policy", "one.json", "--trusted-source-policy", "two.json"],
237+
[
238+
...requiredArgs,
239+
"--trusted-source-policy",
240+
"one.json",
241+
"--trusted-source-policy",
242+
"two.json",
243+
],
231244
],
232245
] satisfies Array<[string, string[]]>;
233246

@@ -616,8 +629,12 @@ describe("resolve-openclaw-package-candidate", () => {
616629
"fs.writeFileSync(process.env.OPENCLAW_TEST_CHILD_PID, String(child.pid));",
617630
"setInterval(() => {}, 1000);",
618631
].join("");
632+
// Accelerate only the module-level 5s forwarded-signal failsafe in this disposable runner.
619633
const runnerScript = [
620-
`import { runCommandForTest } from ${JSON.stringify(scriptUrl)};`,
634+
"const realSetTimeout = globalThis.setTimeout;",
635+
"globalThis.setTimeout = (callback, delay, ...args) =>",
636+
" realSetTimeout(callback, delay === 5000 ? 25 : delay, ...args);",
637+
`const { runCommandForTest } = await import(${JSON.stringify(scriptUrl)});`,
621638
`await runCommandForTest(process.execPath, ['-e', ${JSON.stringify(parentScript)}], { timeoutMs: 60000 });`,
622639
].join("\n");
623640
const runner = spawn(process.execPath, ["--input-type=module", "-e", runnerScript], {
@@ -1336,8 +1353,17 @@ describe("resolve-openclaw-package-candidate", () => {
13361353
const dir = await mkdtemp(path.join(tmpdir(), "openclaw-package-artifact-scan-"));
13371354
tempDirs.push(dir);
13381355

1339-
for (let index = 0; index <= ARTIFACT_TARBALL_SCAN_MAX_ENTRIES; index += 1) {
1340-
await writeFile(path.join(dir, `not-a-package-${index}.txt`), "x");
1356+
// Keep the real 10,001-entry proof while avoiding serial filesystem setup.
1357+
const indexes = Array.from(
1358+
{ length: ARTIFACT_TARBALL_SCAN_MAX_ENTRIES + 1 },
1359+
(_, index) => index,
1360+
);
1361+
for (let start = 0; start < indexes.length; start += 128) {
1362+
await Promise.all(
1363+
indexes
1364+
.slice(start, start + 128)
1365+
.map((index) => writeFile(path.join(dir, `not-a-package-${index}.txt`), "x")),
1366+
);
13411367
}
13421368

13431369
await expect(findSingleTarballForTest(dir)).rejects.toThrow(

0 commit comments

Comments
 (0)