Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 18 additions & 24 deletions .github/scripts/split-tests-by-timings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
// Quality Gate Retries
const RETRIES_FOR_NEW_OR_CHANGED_TESTS = 4;

function readTestResults(TEST_RESULTS_PATH: string): TestRun | undefined {
function readTestResults(TEST_RESULTS_PATH: string): TestRun {
const testSuiteName =
process.env.TEST_SUITE_NAME || 'test-e2e-chrome-browserify';

Expand All @@ -19,9 +19,12 @@ function readTestResults(TEST_RESULTS_PATH: string): TestRun | undefined {
readFileSync(TEST_RESULTS_PATH, 'utf8'),
);

const testRun: TestRun | undefined = testRuns.find(
const testRun: TestRun = testRuns.find(
(run) => run.name === testSuiteName,
);
) || { // If the TestRun is not found, return a dummy object to do the naïve split
name: testSuiteName,
testFiles: [],
};

return testRun;
} catch (error) {
Expand Down Expand Up @@ -82,31 +85,22 @@ export function splitTestsByTimings(
TEST_RESULTS_FILE = `test/test-results/test-runs-${process.env.SELENIUM_BROWSER}.json`,
} = process.env;

try {
const testRunLastTime = readTestResults(TEST_RESULTS_FILE);

if (testRunLastTime) {
let testRunNew: TestRun = { name: testRunLastTime.name, testFiles: [] };
const testRunLastTime = readTestResults(TEST_RESULTS_FILE);
let testRunNew: TestRun = { name: testRunLastTime.name, testFiles: [] };

testList.forEach((path) => {
const testFileLastTime = testRunLastTime.testFiles.find(
(file) => file.path === path,
);

if (testFileLastTime) {
testRunNew.testFiles.push(testFileLastTime);
} else {
testRunNew.testFiles.push(getNewBlankTestFile(path));
}
});
testList.forEach((path) => {
const testFileLastTime = testRunLastTime.testFiles.find(
(file) => file.path === path,
);

return splitTests(testRunNew, changedOrNewTests, totalChunks);
if (testFileLastTime) {
testRunNew.testFiles.push(testFileLastTime);
} else {
testRunNew.testFiles.push(getNewBlankTestFile(path));
}
} catch (error) {
console.trace(error);
}
});

return [];
return splitTests(testRunNew, changedOrNewTests, totalChunks);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Error Handling Regression in Test Splitting

Removing the try-catch block in splitTestsByTimings means errors from readTestResults (e.g., JSON parsing, permission issues) are no longer handled. While readTestResults gracefully handles ENOENT, other errors now propagate up, crashing the process instead of falling back to an empty test chunk array.

Fix in Cursor Fix in Web

Copy link
Member Author

@Gudahtt Gudahtt Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is intentional, the fallback ended up breaking CI anyway. Effectively this case isn't handled gracefully before or after this change.

}

/**
Expand Down
Loading