| 123456789101112131415161718192021222324252627282930 |
- const fs = require('fs'), path = require('path');
- const dir = process.argv[2] || '.worktrees/test-lead-R224/cfc-backend/target/surefire-reports';
- const files = fs.readdirSync(dir).filter(f => /^TEST-.*\.xml$/.test(f));
- let tot = { tests: 0, fail: 0, err: 0, skip: 0 };
- const reds = [];
- for (const f of files) {
- const x = fs.readFileSync(path.join(dir, f), 'utf8');
- const m = x.match(/<testsuite[\s\S]*?>/);
- if (!m) continue;
- const attr = k => {
- const r = new RegExp('\\b' + k + '="(\\d+)"');
- const mm = m[0].match(r);
- return mm ? parseInt(mm[1], 10) : 0;
- };
- const t = attr('tests'), fa = attr('failures'), er = attr('errors'), sk = attr('skipped');
- tot.tests += t; tot.fail += fa; tot.err += er; tot.skip += sk;
- if (fa + er > 0) reds.push({ cls: f.replace(/^TEST-/, '').replace(/\.xml$/, ''), t, fa, er, sk });
- }
- const pass = tot.tests - tot.fail - tot.err - tot.skip;
- const denom = tot.tests - tot.skip;
- console.log(`CLASSES=${files.length} TESTS=${tot.tests} PASS=${pass} FAIL=${tot.fail} ERR=${tot.err} SKIP=${tot.skip} RATE=${denom ? (pass / denom * 100).toFixed(2) : '0'}`);
- const contract = reds.filter(r => /Contract/i.test(r.cls));
- const other = reds.filter(r => !/Contract/i.test(r.cls));
- console.log(`RED_CLASSES=${reds.length} CONTRACT_RED=${contract.length} NONCONTRACT_RED=${other.length}`);
- console.log('--- NONCONTRACT ---');
- other.forEach(r => console.log(`${r.cls} (${r.fa}F/${r.er}E of ${r.t})`));
- if (process.env.SHOW_CONTRACT) {
- console.log('--- CONTRACT ---');
- contract.forEach(r => console.log(`${r.cls} (${r.fa}F/${r.er}E of ${r.t})`));
- }
|