-
Notifications
You must be signed in to change notification settings - Fork 661
Expand file tree
/
Copy pathcompare-test-failures.js
More file actions
46 lines (40 loc) · 1.73 KB
/
Copy pathcompare-test-failures.js
File metadata and controls
46 lines (40 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Compares a TAP run against the known-failures baseline.
// Usage: node compare-test-failures.js <tap-output-file> <baseline-file>
//
// The suite has platform-dependent failures on Mesa/llvmpipe (mostly
// float-packing precision in 'unsigned precision' modes) that predate CI —
// see .github/known-test-failures.txt. This script fails the build only on
// failures that are not in that baseline, so regressions are caught without
// the noise of the pre-existing set. Lines in the baseline that no longer
// fail are reported as candidates for removal.
const fs = require('fs');
const [tapFile, baselineFile] = process.argv.slice(2);
const tap = fs.readFileSync(tapFile, 'utf8');
if (!/^# (pass|fail)\s+\d+$/m.test(tap)) {
console.error('Test run did not complete (no TAP summary found)');
process.exit(1);
}
const failed = new Set();
for (const line of tap.split('\n')) {
const match = line.match(/^not ok \d+ (.*)$/);
if (match) failed.add(match[1].trim());
}
const baseline = new Set(
fs.readFileSync(baselineFile, 'utf8')
.split('\n')
.map(line => line.trim())
.filter(line => line && !line.startsWith('#'))
);
const newFailures = [...failed].filter(name => !baseline.has(name));
const fixed = [...baseline].filter(name => !failed.has(name));
console.log(`${failed.size} failures (${baseline.size} in baseline)`);
if (fixed.length) {
console.log(`\n${fixed.length} baseline entries did not fail this run (flaky or fixed - remove from baseline if consistent):`);
fixed.forEach(name => console.log(` - ${name}`));
}
if (newFailures.length) {
console.error(`\n${newFailures.length} NEW failures not in the baseline:`);
newFailures.forEach(name => console.error(` ! ${name}`));
process.exit(1);
}
console.log('\nNo new failures.');