Download automation/scripts/case-map.js from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 9.28 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/automation/scripts/case-map.js
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/automation/scripts/case-map.js
-
curl -L -o case-map.js https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/automation/scripts/case-map.js
9.28 kB
| // Writes results/case-map.json + results/case-map.md: every YAML case (all modules; tests/cases/*.yaml and | |
| // tests/cases/<module>/*.yaml) with module, tier, automation status and run outcome, plus per-module and per-tier counts. | |
| // MOCK-only results; nothing here was run against Oracle Fusion. | |
| const fs = require('fs'); const path = require('path'); const YAML = require('yaml'); | |
| const root = path.resolve(__dirname, '..'); const casesDir = path.resolve(root, '../tests/cases'); | |
| const resultsPath = path.resolve(root, process.env.CASE_MAP_RESULTS || 'results/results.json'); | |
| const outDir = path.resolve(root, process.env.CASE_MAP_OUTDIR || 'results'); | |
| const tiers = (process.env.RUN_TIERS || 'P1,P2').split(',').map((s) => s.trim().toUpperCase()); | |
| const ID_RE = /^([A-Z][A-Z0-9]{1,5})-[A-Z0-9]+-\d+$/; | |
| const heldRun = String(process.env.HELD_RUN_MODULES || 'HCM').split(',').map((x) => x.trim().toUpperCase()).filter(Boolean); // execution_hold modules that may run on the MOCK (CX never) | |
| const suite = (() => { const v = String(process.env.CASE_MAP_SUITE || process.env.RUN_SUITE || 'gate').toLowerCase(); return v === 'tolerant' || v === 'held' ? v : 'gate'; })(); | |
| // Lifecycle (tests/README.md; same precedence as qa/audit.py): retired > held > tolerant. | |
| const lifecycle = (c) => (String(c.status || '').toLowerCase() === 'retired' ? 'retired' : String(c.execution_hold || '').trim() ? 'held' | |
| : (String(c.suite || '').toLowerCase() === 'tolerant' || ['false', 'no', '0'].includes(String(c.go_no_go ?? '').toLowerCase())) ? 'tolerant' : null); | |
| const modules = (process.env.RUN_MODULES || '').split(',').map((s) => s.trim().toUpperCase()).filter(Boolean); | |
| const walkFiles = (dir, test) => !fs.existsSync(dir) ? [] : fs.readdirSync(dir, { withFileTypes: true }).flatMap((e) => e.isDirectory() ? (/^[._]/.test(e.name) ? [] : walkFiles(path.join(dir, e.name), test)) : test(e.name) ? [path.join(dir, e.name)] : []); | |
| const cases = walkFiles(casesDir, (n) => /\.ya?ml$/.test(n)).map((f) => YAML.parse(fs.readFileSync(f, 'utf8'))).filter((c) => c && ID_RE.test(c.id)) | |
| .map((c) => ({ ...c, moduleId: String(c.module || ID_RE.exec(c.id)[1]).toUpperCase(), lc: lifecycle(c) })) | |
| .filter((c) => (suite === 'gate' ? true : c.lc === suite)).sort((a, b) => a.id.localeCompare(b.id)); | |
| const specs = new Set(walkFiles(path.join(root, 'tests/cases'), (n) => n.endsWith('.spec.ts')).map((f) => path.basename(f).replace('.spec.ts', ''))); | |
| const outcomes = {}; | |
| if (fs.existsSync(resultsPath)) { | |
| const r = JSON.parse(fs.readFileSync(resultsPath, 'utf8')); | |
| const walk = (s) => { (s.specs || []).forEach((sp) => sp.tests.forEach((t) => { | |
| const id = (sp.tags || []).map((x) => x.replace(/^@/, '')).find((x) => ID_RE.test(x)) || (/^([A-Z][A-Z0-9]{1,5}-[A-Z0-9]+-\d+)/.exec(sp.title) || [])[1]; | |
| const res = t.results[t.results.length - 1] || {}; | |
| const ann = (t.annotations || []).find((a) => a.type === 'fixme' || a.type === 'skip'); | |
| if (id) outcomes[id] = { status: t.status === 'skipped' && ann ? 'fixme' : (res.status || t.status), expected: t.expectedStatus, durationMs: res.duration, reason: ann?.description, attachments: (res.attachments || []).map((a) => a.path).filter(Boolean) }; | |
| })); (s.suites || []).forEach(walk); }; | |
| (r.suites || []).forEach(walk); | |
| } else console.warn(`No results at ${resultsPath}`); | |
| const rows = cases.map((c) => { | |
| const scripted = specs.has(c.id); const o = outcomes[c.id]; | |
| let automation; | |
| if (c.lc === 'retired') automation = 'retired'; | |
| else if (c.lc === 'tolerant' && suite === 'gate') automation = 'tolerant-suite'; | |
| else if (c.lc === 'held' && suite === 'gate') automation = scripted ? 'held-scripted' : 'held'; | |
| else if (c.lc === 'held' && suite === 'held' && !heldRun.includes(c.moduleId)) automation = scripted ? 'held-scripted (never run)' : 'held (never run)'; | |
| else if (!scripted) automation = ['P3', 'P4'].includes(c.priority) ? 'deferred' : 'unscripted-gap'; | |
| else if (o?.status === 'fixme') automation = 'fixme'; | |
| else automation = 'scripted'; | |
| const inRun = tiers.includes(c.priority) && (!modules.length || modules.includes(c.moduleId)) && !['retired'].includes(c.lc) && !(c.lc === 'tolerant' && suite === 'gate') && !(c.lc === 'held' && suite === 'gate') && !(c.lc === 'held' && !heldRun.includes(c.moduleId)); | |
| return { id: c.id, module: c.moduleId, priority: c.priority, title: c.title, standIn: c.stand_in || null, lifecycle: c.lc, automation, inRunTiers: tiers.includes(c.priority), inRun, outcome: o ? o.status : (scripted && inRun ? 'not-run' : null), reason: o?.reason || (automation === 'deferred' ? `${c.priority} deferred by scope (P1 then P2 only)` : undefined) }; | |
| }); | |
| const byTier = {}; const byModule = {}; | |
| const blank = () => ({ total: 0, scripted: 0, fixme: 0, deferred: 0, gap: 0, passed: 0, failed: 0, notRun: 0, tolerant: 0, retired: 0, held: 0 }); | |
| const count = (t, r) => { t.total++; if (r.automation === 'tolerant-suite') t.tolerant++; if (String(r.automation).startsWith('held')) t.held++; if (r.automation === 'retired') t.retired++; if (r.automation === 'scripted') t.scripted++; if (r.automation === 'fixme') t.fixme++; if (r.automation === 'deferred') t.deferred++; if (r.automation === 'unscripted-gap') t.gap++; | |
| if (r.outcome === 'passed') t.passed++; if (['failed', 'timedOut', 'interrupted'].includes(r.outcome)) t.failed++; if (r.outcome === 'not-run') t.notRun++; }; | |
| for (const r of rows) { const m = (byModule[r.module] = byModule[r.module] || { ...blank(), byTier: {} }); count(m, r); count((m.byTier[r.priority] = m.byTier[r.priority] || blank()), r); } | |
| for (const r of rows) { const t = (byTier[r.priority] = byTier[r.priority] || blank()); | |
| t.total++; if (r.automation === 'tolerant-suite') t.tolerant++; if (String(r.automation).startsWith('held')) t.held++; if (r.automation === 'retired') t.retired++; if (r.automation === 'scripted') t.scripted++; if (r.automation === 'fixme') t.fixme++; if (r.automation === 'deferred') t.deferred++; if (r.automation === 'unscripted-gap') t.gap++; | |
| if (r.outcome === 'passed') t.passed++; if (['failed', 'timedOut', 'interrupted'].includes(r.outcome)) t.failed++; if (r.outcome === 'not-run') t.notRun++; } | |
| const extra = Object.entries(outcomes).filter(([id]) => !cases.find((c) => c.id === id)).map(([id, o]) => ({ id, status: o.status })); | |
| const out = { generatedAt: new Date().toISOString(), target: 'local MOCK app (not Oracle Fusion)', suite, runTiers: tiers, runModules: modules.length ? modules : 'ALL', results: path.relative(root, resultsPath), byModule, byTier, nonCaseTests: extra, cases: rows }; | |
| fs.mkdirSync(outDir, { recursive: true }); | |
| fs.writeFileSync(path.join(outDir, 'case-map.json'), JSON.stringify(out, null, 2)); | |
| const md = [`# Case map (MOCK run; not Oracle Fusion)${suite === 'tolerant' ? ' - TOLERANT suite (suite: tolerant / go_no_go: false; not go/no-go input)' : ''}`, '', suite === 'gate' ? 'Tolerant cases run in a separate suite (results/tolerant/); held (execution_hold) cases are out of go/no-go scope (scripted HCM cases run on the MOCK only in results/held/; CX is never run); retired cases are never run. None of these count as gaps here.' : '', '', `Run tiers: ${tiers.join(', ')} | results: ${out.results}`, '', | |
| `Run modules: ${modules.length ? modules.join(', ') : 'ALL'}`, '', | |
| '| Module | Tier | Total | Scripted | Passed | Failed | fixme | Deferred | Gap | Not run | Tolerant (separate) | Held (execution_hold) | Retired |', '|---|---|---|---|---|---|---|---|---|---|---|---|---|', | |
| ...Object.keys(byModule).sort().flatMap((m) => [...Object.keys(byModule[m].byTier).sort().map((k) => [k, byModule[m].byTier[k]]), ['all', byModule[m]]].map(([k, t]) => `| ${m} | ${k} | ${t.total} | ${t.scripted} | ${t.passed} | ${t.failed} | ${t.fixme} | ${t.deferred} | ${t.gap} | ${t.notRun} | ${t.tolerant} | ${t.held} | ${t.retired} |`)), | |
| '', '| Tier (all modules) | Total | Scripted | Passed | Failed | fixme | Deferred | Gap | Not run |', '|---|---|---|---|---|---|---|---|---|', | |
| ...Object.keys(byTier).sort().map((k) => { const t = byTier[k]; return `| ${k} | ${t.total} | ${t.scripted} | ${t.passed} | ${t.failed} | ${t.fixme} | ${t.deferred} | ${t.gap} | ${t.notRun} |`; }), | |
| '', '| Case | Module | Tier | Automation | Outcome | Note |', '|---|---|---|---|---|---|', | |
| ...rows.map((r) => `| ${r.id} | ${r.module} | ${r.priority} | ${r.automation}${r.standIn ? ' (stand-in)' : ''} | ${r.outcome ?? '-'} | ${(r.reason || '').replace(/\|/g, '/')} |`), | |
| '', extra.length ? `Non-case tests: ${extra.map((e) => `${e.id}=${e.status}`).join(', ')}` : ''].join('\n'); | |
| fs.writeFileSync(path.join(outDir, 'case-map.md'), md + '\n'); | |
| console.log(`case-map [${suite}] by module:`, Object.keys(byModule).sort().map((m) => { const t = byModule[m]; return `${m} ${t.passed}/${t.scripted} passed, ${t.failed} failed, ${t.fixme} fixme, ${t.gap} gap, ${t.deferred} deferred${t.held ? `, ${t.held} held` : ''}${t.tolerant ? `, ${t.tolerant} tolerant` : ''}`; }).join(' | ')); | |
| console.log(`case-map [${suite}] by tier:`, Object.keys(byTier).sort().map((k) => `${k} ${byTier[k].passed}/${byTier[k].scripted} passed, ${byTier[k].failed} failed, ${byTier[k].fixme} fixme, ${byTier[k].deferred} deferred`).join(' | ')); | |