Skip to content

Commit ef40333

Browse files
Isolate script test runner files
1 parent 7ffcc1b commit ef40333

3 files changed

Lines changed: 50 additions & 11 deletions

File tree

scripts/release/gh-release.test.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { promisify } from "node:util";
99
const execFileAsync = promisify(execFile);
1010
const repoRoot = process.cwd();
1111
const scriptPath = path.join(repoRoot, "scripts", "release", "gh-release.sh");
12+
const FIXTURE_RELEASE_HELPER_TIMEOUT_MS = 15_000;
1213

1314
function escapeRegExp(value: string): string {
1415
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -208,7 +209,7 @@ async function runFixtureReleaseHelper(fixture: {
208209
RAY_TEST_LOG: fixture.logPath,
209210
},
210211
maxBuffer: 64 * 1024,
211-
timeout: 5_000,
212+
timeout: FIXTURE_RELEASE_HELPER_TIMEOUT_MS,
212213
});
213214

214215
return { code: 0, stderr, stdout };
@@ -222,6 +223,27 @@ async function runFixtureReleaseHelper(fixture: {
222223
}
223224
}
224225

226+
async function assertFixtureReleaseHelperSucceeded(
227+
fixture: { logPath: string },
228+
result: { code: number; stderr: string; stdout: string },
229+
): Promise<void> {
230+
const commandLog = await readFile(fixture.logPath, "utf8").catch(() => "");
231+
232+
assert.equal(
233+
result.code,
234+
0,
235+
[
236+
"expected release helper fixture to exit 0",
237+
"stdout:",
238+
result.stdout,
239+
"stderr:",
240+
result.stderr,
241+
"commands:",
242+
commandLog,
243+
].join("\n"),
244+
);
245+
}
246+
225247
test("gh release helper validates syntax and dry-runs without mutating git state", async () => {
226248
const version = await readCurrentVersion();
227249
const escapedVersion = escapeRegExp(version);
@@ -323,7 +345,7 @@ test("gh release helper continues when GitHub reports releases are missing", asy
323345

324346
const result = await runFixtureReleaseHelper(fixture);
325347

326-
assert.equal(result.code, 0);
348+
await assertFixtureReleaseHelperSucceeded(fixture, result);
327349
assert.match(
328350
result.stdout,
329351
/Done\. Actions publish to npm when each release is in published state\./,
@@ -352,7 +374,7 @@ test("gh release helper reuses matching local annotated tags", async (t) => {
352374

353375
const result = await runFixtureReleaseHelper(fixture);
354376

355-
assert.equal(result.code, 0);
377+
await assertFixtureReleaseHelperSucceeded(fixture, result);
356378
assert.match(result.stdout, /Reusing local annotated tag core-v1\.2\.3/);
357379
assert.match(result.stdout, /Reusing local annotated tag sdk-v1\.2\.3/);
358380

@@ -378,7 +400,7 @@ test("gh release helper resumes after remote tags or releases already exist safe
378400

379401
const result = await runFixtureReleaseHelper(fixture);
380402

381-
assert.equal(result.code, 0);
403+
await assertFixtureReleaseHelperSucceeded(fixture, result);
382404
assert.match(result.stdout, /Reusing remote annotated tag core-v1\.2\.3/);
383405
assert.match(result.stdout, /Reusing remote annotated tag sdk-v1\.2\.3/);
384406
assert.match(result.stdout, /Reusing GitHub release core-v1\.2\.3/);

scripts/test-runner.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ test("runTestCli dispatches bounded built tests before script tests", async (t)
158158
await mkdir(path.join(tempDir, "scripts"), { recursive: true });
159159
await writeFile(path.join(tempDir, "apps", "gateway", "dist", "index.test.js"), "");
160160
await writeFile(path.join(tempDir, "scripts", "package-runtime-coverage.test.ts"), "");
161+
await writeFile(path.join(tempDir, "scripts", "validate-configs.test.ts"), "");
161162

162163
const commands: Array<{ binary: string; args: string[]; cwd?: string; timeoutMs?: number }> = [];
163164
const code = await runTestCli({
@@ -179,7 +180,7 @@ test("runTestCli dispatches bounded built tests before script tests", async (t)
179180
});
180181

181182
assert.equal(code, 0);
182-
assert.equal(commands.length, 2);
183+
assert.equal(commands.length, 3);
183184
assert.equal(commands[0]?.binary, "/usr/local/bin/node");
184185
assert.deepEqual(commands[0]?.args.slice(0, 2), ["--test", "--test-concurrency=1"]);
185186
assert.equal(
@@ -200,6 +201,16 @@ test("runTestCli dispatches bounded built tests before script tests", async (t)
200201
);
201202
assert.equal(commands[1]?.cwd, tempDir);
202203
assert.equal(commands[1]?.timeoutMs, 123_456);
204+
assert.equal(commands[2]?.binary, "/usr/local/bin/bun");
205+
assert.deepEqual(commands[2]?.args.slice(0, 3), [
206+
"test",
207+
"--max-concurrency=1",
208+
"--timeout=120000",
209+
]);
210+
assert.equal(commands[2]?.args.length, 4);
211+
assert.equal(commands[2]?.args.at(-1), path.join(tempDir, "scripts", "validate-configs.test.ts"));
212+
assert.equal(commands[2]?.cwd, tempDir);
213+
assert.equal(commands[2]?.timeoutMs, 123_456);
203214
});
204215

205216
test("runTestCli rejects malformed runtime binary overrides before dispatch", async (t) => {

scripts/test.mjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,19 @@ export async function runTestCli(options = {}) {
613613
return 0;
614614
}
615615

616-
code = await runCommand(
617-
bunBinary,
618-
["test", "--max-concurrency=1", "--timeout=120000", ...discovered.scriptTestFiles],
619-
{ cwd: root, env, timeoutMs: commandTimeoutMs, io },
620-
);
616+
for (const scriptTestFile of discovered.scriptTestFiles) {
617+
code = await runCommand(
618+
bunBinary,
619+
["test", "--max-concurrency=1", "--timeout=120000", scriptTestFile],
620+
{ cwd: root, env, timeoutMs: commandTimeoutMs, io },
621+
);
622+
623+
if (code !== 0) {
624+
return code;
625+
}
626+
}
621627

622-
return code;
628+
return 0;
623629
}
624630

625631
export async function runTestRunnerCli(options = {}, io = process) {

0 commit comments

Comments
 (0)