fix: normalize runtime diagnostics

This commit is contained in:
bincxz committed 2026-07-31 20:29:03 +08:00
1 parent 6e8e38d00b
commit 025eb06f1f
2 files changed
+23 -10

No files matched your search

+13 -10
View File
@@ -4,22 +4,25 @@ const fs = require('node:fs');
const ANSI_RE = /\x1b\[[0-?]*[ -/]*[@-~]/g;
function normalizeAssertionDetail(detail) {
function normalizeRuntimeDetail(detail) {
return detail
.replace(
/\b(now|timestamp|pid|nonce|random(?:Value)?)\b(['"]?\s*[:=]\s*)[^,\s}\]]+/gi,
'$1$2<volatile>',
)
.replace(
/\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z\b/g,
'<timestamp>',
);
)
.replace(/(?:\/private)?\/var\/folders\/\S+|\/tmp\/\S+/g, '<tmp-path>')
.replace(/:\d+:\d+\b/g, ':<line>:<column>');
}
function normalizeAssertionDetail(detail) {
return normalizeRuntimeDetail(detail).replace(
/\b(now|timestamp|pid|nonce|random(?:Value)?)\b(['"]?\s*[:=]\s*)[^,\s}\]]+/gi,
'$1$2<volatile>',
);
}
function normalizeStableDiagnosticDetail(detail) {
return normalizeAssertionDetail(detail)
.replace(/(?:\/private)?\/var\/folders\/\S+|\/tmp\/\S+/g, '<tmp-path>')
.replace(/:\d+:\d+\b/g, ':<line>:<column>');
return normalizeAssertionDetail(detail);
}
function collectNonTapOutput(lines) {
@@ -152,7 +155,7 @@ function parseTapResult(text, exitCode) {
);
const stableErrorDetails = assertionFailure
? errorDetails.map(normalizeStableDiagnosticDetail)
: errorDetails;
: errorDetails.map(normalizeRuntimeDetail);
diagnostic.push(...stableErrorDetails.map((detail) => `error-detail: ${detail}`));
failures.push(name);
failureRecords.push({
+10
View File
@@ -324,6 +324,16 @@ test('distinguishes same-title failures by stable TAP diagnostics', () => {
parseTapResult(customMultilineError('service rejected: new reason'), 1),
);
assert.equal(changedCustomError.passed, false);
const sameCustomErrorAcrossRuns = compareTapResults(
parseTapResult(customMultilineError(
'service failed at /tmp/run-A/result on 2026-07-31T10:00:00Z in worker.js:10:2',
), 1),
parseTapResult(customMultilineError(
'service failed at /tmp/run-B/result on 2026-07-31T10:01:00Z in worker.js:11:3',
), 1),
);
assert.equal(sameCustomErrorAcrossRuns.passed, true);
});
test('rejects added duplicate failures, cancellations, skipped tests, and TODOs', () => {