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 () => {