_r224_agg.cjs 1.6 KB

123456789101112131415161718192021222324252627282930
  1. const fs = require('fs'), path = require('path');
  2. const dir = process.argv[2] || '.worktrees/test-lead-R224/cfc-backend/target/surefire-reports';
  3. const files = fs.readdirSync(dir).filter(f => /^TEST-.*\.xml$/.test(f));
  4. let tot = { tests: 0, fail: 0, err: 0, skip: 0 };
  5. const reds = [];
  6. for (const f of files) {
  7. const x = fs.readFileSync(path.join(dir, f), 'utf8');
  8. const m = x.match(/<testsuite[\s\S]*?>/);
  9. if (!m) continue;
  10. const attr = k => {
  11. const r = new RegExp('\\b' + k + '="(\\d+)"');
  12. const mm = m[0].match(r);
  13. return mm ? parseInt(mm[1], 10) : 0;
  14. };
  15. const t = attr('tests'), fa = attr('failures'), er = attr('errors'), sk = attr('skipped');
  16. tot.tests += t; tot.fail += fa; tot.err += er; tot.skip += sk;
  17. if (fa + er > 0) reds.push({ cls: f.replace(/^TEST-/, '').replace(/\.xml$/, ''), t, fa, er, sk });
  18. }
  19. const pass = tot.tests - tot.fail - tot.err - tot.skip;
  20. const denom = tot.tests - tot.skip;
  21. 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'}`);
  22. const contract = reds.filter(r => /Contract/i.test(r.cls));
  23. const other = reds.filter(r => !/Contract/i.test(r.cls));
  24. console.log(`RED_CLASSES=${reds.length} CONTRACT_RED=${contract.length} NONCONTRACT_RED=${other.length}`);
  25. console.log('--- NONCONTRACT ---');
  26. other.forEach(r => console.log(`${r.cls} (${r.fa}F/${r.er}E of ${r.t})`));
  27. if (process.env.SHOW_CONTRACT) {
  28. console.log('--- CONTRACT ---');
  29. contract.forEach(r => console.log(`${r.cls} (${r.fa}F/${r.er}E of ${r.t})`));
  30. }