From b131639cc545af23e568feb68e7d5c14c2778b20 Mon Sep 17 00:00:00 2001 From: Michael H Date: Sat, 8 Nov 2025 16:49:58 +1100 Subject: [PATCH] ci: run modified tests first (#24463) Co-authored-by: Meghan Denny --- scripts/runner.node.mjs | 21 +++++++++++++++++++++ test/cli/console-depth.test.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index abdf911968..dd566d2b27 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -1891,6 +1891,27 @@ function getRelevantTests(cwd, testModifiers, testExpectations) { filteredTests.push(...availableTests); } + // Prioritize modified test files + if (allFiles.length > 0) { + const modifiedTests = new Set( + allFiles + .filter(filename => filename.startsWith("test/") && isTest(filename)) + .map(filename => filename.slice("test/".length)), + ); + + if (modifiedTests.size > 0) { + return filteredTests + .map(testPath => testPath.replaceAll("\\", "/")) + .sort((a, b) => { + const aModified = modifiedTests.has(a); + const bModified = modifiedTests.has(b); + if (aModified && !bModified) return -1; + if (!aModified && bModified) return 1; + return 0; + }); + } + } + return filteredTests; } diff --git a/test/cli/console-depth.test.ts b/test/cli/console-depth.test.ts index 5cb8cf4df4..9660d73b73 100644 --- a/test/cli/console-depth.test.ts +++ b/test/cli/console-depth.test.ts @@ -28,7 +28,7 @@ describe("console depth", () => { function normalizeOutput(output: string): string { // Normalize line endings and trim whitespace - return output.replace(/\r\n/g, "\n").replace(/\r/g, "\n").trim(); + return output.replace(/\r\n?/g, "\n").trim(); } test("default console depth should be 2", async () => {