Skip to content

Commit b5e386c

Browse files
committed
Stricter
1 parent c9e6638 commit b5e386c

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

internal/fourslash/_scripts/updateFailing.mts

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,26 @@ async function main() {
6969
// Process failed tests
7070
if (event.Action === "fail" && event.Test) {
7171
const outputs = testOutputs.get(event.Test) || [];
72-
const fullOutput = outputs.join("");
73-
74-
// Check if this is a baseline-only failure
75-
// Baseline failures contain specific messages from baseline.go
76-
const hasBaselineMessage = /new baseline created at/.test(fullOutput) ||
77-
/the baseline file .* has changed/.test(fullOutput);
78-
79-
// Check for non-baseline errors
80-
// Look for patterns that indicate real test failures
81-
// We need to filter out baseline messages when checking for errors
82-
const outputWithoutBaseline = fullOutput
83-
.replace(/the baseline file .* has changed\. \(Run `hereby baseline-accept` if the new baseline is correct\.\)/g, "")
84-
.replace(/new baseline created at .*\./g, "")
85-
.replace(/the baseline file .* does not exist in the TypeScript submodule/g, "")
86-
.replace(/the baseline file .* does not match the reference in the TypeScript submodule/g, "");
87-
88-
const hasNonBaselineError = /^panic/m.test(outputWithoutBaseline) ||
89-
/Error|error/i.test(outputWithoutBaseline) ||
90-
/fatal|Fatal/.test(outputWithoutBaseline) ||
91-
/Unexpected/.test(outputWithoutBaseline);
92-
93-
// Only mark as failing if it's not a baseline-only failure
94-
// (i.e., if there's no baseline message, or if there are other errors besides baseline)
95-
if (!hasBaselineMessage || hasNonBaselineError) {
72+
73+
// A test is only considered a baseline-only failure if ALL error messages
74+
// are baseline-related. Any non-baseline error message means it's a real failure.
75+
const baselineMessagePatterns = [
76+
/^\s*baseline\.go:\d+: the baseline file .* has changed\./,
77+
/^\s*baseline\.go:\d+: new baseline created at /,
78+
/^\s*baseline\.go:\d+: the baseline file .* does not exist in the TypeScript submodule/,
79+
/^\s*baseline\.go:\d+: the baseline file .* does not match the reference in the TypeScript submodule/,
80+
];
81+
82+
// Check each output line that looks like an error message
83+
// Error messages from Go tests typically contain ".go:" with a line number
84+
const errorLines = outputs.filter(line => /^\s*\w+\.go:\d+:/.test(line));
85+
86+
// If there are no error lines, it's a real failure.
87+
// If all error lines match baseline patterns, it's a baseline-only failure
88+
const isBaselineOnlyFailure = errorLines.length > 0 &&
89+
errorLines.every(line => baselineMessagePatterns.some(pattern => pattern.test(line)));
90+
91+
if (!isBaselineOnlyFailure) {
9692
failingTests.push(event.Test);
9793
}
9894
}

0 commit comments

Comments
 (0)