abapgit-agent 1.17.6 → 1.17.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/unit.js +32 -16
package/package.json
CHANGED
package/src/commands/unit.js
CHANGED
|
@@ -327,23 +327,8 @@ Examples:
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
// JUnit output mode — write XML, then continue to normal output
|
|
331
|
-
if (junitOutput) {
|
|
332
|
-
const xml = buildUnitJUnit(results);
|
|
333
|
-
const outputPath = pathModule.isAbsolute(junitOutput)
|
|
334
|
-
? junitOutput
|
|
335
|
-
: pathModule.join(process.cwd(), junitOutput);
|
|
336
|
-
const dir = pathModule.dirname(outputPath);
|
|
337
|
-
if (!fs.existsSync(dir)) {
|
|
338
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
339
|
-
}
|
|
340
|
-
fs.writeFileSync(outputPath, xml, 'utf8');
|
|
341
|
-
if (!jsonOutput) {
|
|
342
|
-
console.log(` JUnit report written to: ${outputPath}`);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
330
|
// Coverage threshold enforcement — aggregated across all files
|
|
331
|
+
// Runs BEFORE JUnit output so the synthetic failure testcase lands in the XML.
|
|
347
332
|
if (coverage && coverageThreshold > 0) {
|
|
348
333
|
const totalLines = results.reduce((s, r) => s + ((r.COVERAGE_STATS || r.coverage_stats)?.TOTAL_LINES || (r.COVERAGE_STATS || r.coverage_stats)?.total_lines || 0), 0);
|
|
349
334
|
const coveredLines = results.reduce((s, r) => s + ((r.COVERAGE_STATS || r.coverage_stats)?.COVERED_LINES || (r.COVERAGE_STATS || r.coverage_stats)?.covered_lines || 0), 0);
|
|
@@ -359,6 +344,21 @@ Examples:
|
|
|
359
344
|
} else {
|
|
360
345
|
if (!jsonOutput) console.error(`❌ ${msg}`);
|
|
361
346
|
hasErrors = true;
|
|
347
|
+
// Inject a synthetic failing testcase so the JUnit report shows the failure,
|
|
348
|
+
// not just a passing test badge alongside a red build.
|
|
349
|
+
results.push({
|
|
350
|
+
_className: 'Coverage',
|
|
351
|
+
_synthetic: true,
|
|
352
|
+
TEST_COUNT: 1,
|
|
353
|
+
PASSED_COUNT: 0,
|
|
354
|
+
FAILED_COUNT: 1,
|
|
355
|
+
ERRORS: [{
|
|
356
|
+
CLASS_NAME: 'Coverage',
|
|
357
|
+
METHOD_NAME: 'coverage_threshold',
|
|
358
|
+
ERROR_KIND: 'FAILURE',
|
|
359
|
+
ERROR_TEXT: msg
|
|
360
|
+
}]
|
|
361
|
+
});
|
|
362
362
|
}
|
|
363
363
|
} else {
|
|
364
364
|
if (!jsonOutput) console.log(`✅ Coverage ${rate}% meets threshold ${coverageThreshold}%`);
|
|
@@ -366,6 +366,22 @@ Examples:
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
// JUnit output mode — write XML after threshold check so synthetic failure is included
|
|
370
|
+
if (junitOutput) {
|
|
371
|
+
const xml = buildUnitJUnit(results);
|
|
372
|
+
const outputPath = pathModule.isAbsolute(junitOutput)
|
|
373
|
+
? junitOutput
|
|
374
|
+
: pathModule.join(process.cwd(), junitOutput);
|
|
375
|
+
const dir = pathModule.dirname(outputPath);
|
|
376
|
+
if (!fs.existsSync(dir)) {
|
|
377
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
378
|
+
}
|
|
379
|
+
fs.writeFileSync(outputPath, xml, 'utf8');
|
|
380
|
+
if (!jsonOutput) {
|
|
381
|
+
console.log(` JUnit report written to: ${outputPath}`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
369
385
|
// JSON output mode
|
|
370
386
|
if (jsonOutput) {
|
|
371
387
|
console.log(JSON.stringify(results, null, 2));
|