taf-git 0.0.0-stage → 3.0.0
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/CHANGELOG.md +413 -0
- package/LICENSE +21 -0
- package/README.md +266 -2
- package/RECEIPT-FORMAT.md +100 -0
- package/dist/badge.d.ts +23 -0
- package/dist/badge.js +150 -0
- package/dist/badge.js.map +1 -0
- package/dist/cli.d.ts +42 -0
- package/dist/cli.js +323 -0
- package/dist/cli.js.map +1 -0
- package/dist/git-env.d.ts +20 -0
- package/dist/git-env.js +45 -0
- package/dist/git-env.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/parsers/bun.d.ts +58 -0
- package/dist/parsers/bun.js +126 -0
- package/dist/parsers/bun.js.map +1 -0
- package/dist/parsers/index.d.ts +21 -0
- package/dist/parsers/index.js +63 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/jest.d.ts +41 -0
- package/dist/parsers/jest.js +87 -0
- package/dist/parsers/jest.js.map +1 -0
- package/dist/parsers/junit.d.ts +24 -0
- package/dist/parsers/junit.js +144 -0
- package/dist/parsers/junit.js.map +1 -0
- package/dist/parsers/vitest.d.ts +16 -0
- package/dist/parsers/vitest.js +61 -0
- package/dist/parsers/vitest.js.map +1 -0
- package/dist/parsers/wjttc.d.ts +37 -0
- package/dist/parsers/wjttc.js +152 -0
- package/dist/parsers/wjttc.js.map +1 -0
- package/dist/receipt-push.d.ts +38 -0
- package/dist/receipt-push.js +63 -0
- package/dist/receipt-push.js.map +1 -0
- package/dist/skipped-names.d.ts +60 -0
- package/dist/skipped-names.js +159 -0
- package/dist/skipped-names.js.map +1 -0
- package/dist/taf-core.d.ts +32 -0
- package/dist/taf-core.js +303 -0
- package/dist/taf-core.js.map +1 -0
- package/package.json +64 -4
- package/project.faf +57 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unified test output parser
|
|
4
|
+
*
|
|
5
|
+
* Tries each framework parser in order until one succeeds.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.NO_TESTS = exports.UNPARSEABLE_OUTPUT = exports.SUPPORTED_PARSERS = exports.parseWjttcOutput = exports.parseJunitOutput = void 0;
|
|
9
|
+
exports.noResultsReason = noResultsReason;
|
|
10
|
+
exports.parseTestOutput = parseTestOutput;
|
|
11
|
+
const bun_1 = require("./bun");
|
|
12
|
+
const jest_1 = require("./jest");
|
|
13
|
+
const junit_1 = require("./junit");
|
|
14
|
+
const vitest_1 = require("./vitest");
|
|
15
|
+
const wjttc_1 = require("./wjttc");
|
|
16
|
+
var junit_2 = require("./junit");
|
|
17
|
+
Object.defineProperty(exports, "parseJunitOutput", { enumerable: true, get: function () { return junit_2.parseJunitOutput; } });
|
|
18
|
+
var wjttc_2 = require("./wjttc");
|
|
19
|
+
Object.defineProperty(exports, "parseWjttcOutput", { enumerable: true, get: function () { return wjttc_2.parseWjttcOutput; } });
|
|
20
|
+
/**
|
|
21
|
+
* Every parser, in the order parseTestOutput tries them. Order matters:
|
|
22
|
+
* 1. JUnit XML — a `<testsuite>` element; first, because a report's captured
|
|
23
|
+
* stdout can hold another runner's summary line.
|
|
24
|
+
* 2. Bun — `Ran N tests across M files` is bun-unique.
|
|
25
|
+
* 3. WJTTC — `pc-ai WJTTC` / suite `pc-ai-wjttc` (FAF bar; not Jest-shaped).
|
|
26
|
+
* 4. Jest — `Tests: … total`.
|
|
27
|
+
* 5. Vitest — `Tests … (N)`.
|
|
28
|
+
*/
|
|
29
|
+
const PARSERS = [
|
|
30
|
+
['JUnit XML', junit_1.parseJunitOutput],
|
|
31
|
+
['Bun', bun_1.parseBunOutput],
|
|
32
|
+
['WJTTC', wjttc_1.parseWjttcOutput],
|
|
33
|
+
['Jest', jest_1.parseJestOutput],
|
|
34
|
+
['Vitest', vitest_1.parseVitestOutput],
|
|
35
|
+
];
|
|
36
|
+
exports.SUPPORTED_PARSERS = PARSERS.map(([name]) => name);
|
|
37
|
+
/** What the CLI and the Action report when no parser matches. */
|
|
38
|
+
exports.UNPARSEABLE_OUTPUT = `Could not parse test output. Supported: ${exports.SUPPORTED_PARSERS.join(', ')}.`;
|
|
39
|
+
/** A JUnit report that lists no tests (node --test with no test files): nothing ran, so no receipt. */
|
|
40
|
+
exports.NO_TESTS = 'No tests ran: the JUnit report lists 0 tests, so there is no receipt to print.';
|
|
41
|
+
/** Why the output gave no results: no tests at all, or a format taf-git doesn't read. */
|
|
42
|
+
function noResultsReason(output) {
|
|
43
|
+
const xml = output.replace(/<!--[\s\S]*?-->/g, '');
|
|
44
|
+
const junitShaped = /<testsuites?\b/.test(xml);
|
|
45
|
+
return junitShaped && !/<testcase\b/.test(xml) && !/\btests\s*=\s*["'][1-9]/.test(xml) ? exports.NO_TESTS : exports.UNPARSEABLE_OUTPUT;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse test output from any supported framework: the first parser in
|
|
49
|
+
* PARSERS that recognises the output wins.
|
|
50
|
+
*/
|
|
51
|
+
function parseTestOutput(output) {
|
|
52
|
+
for (const [, parse] of PARSERS) {
|
|
53
|
+
const results = parse(output);
|
|
54
|
+
if (results)
|
|
55
|
+
return allSkipped(results) ? { ...results, result: 'SKIPPED' } : results;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/** Tests were found, but none passed and none failed: every one was skipped. */
|
|
60
|
+
function allSkipped(r) {
|
|
61
|
+
return r.total > 0 && r.passed === 0 && r.failed === 0;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parsers/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAuCH,0CAIC;AAMD,0CAMC;AApDD,+BAAuC;AACvC,iCAAyC;AACzC,mCAA2C;AAC3C,qCAA6C;AAC7C,m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C,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IACxF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gFAAgF;AAChF,SAAS,UAAU,CAAC,CAAc;IAChC,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jest output parser
|
|
3
|
+
*
|
|
4
|
+
* Extracts test counts from Jest CLI output
|
|
5
|
+
*/
|
|
6
|
+
export interface TestResults {
|
|
7
|
+
total: number;
|
|
8
|
+
passed: number;
|
|
9
|
+
failed: number;
|
|
10
|
+
skipped?: number;
|
|
11
|
+
/** Names of the skipped tests, when the output names them (raw; normalised when written). */
|
|
12
|
+
skippedNames?: string[];
|
|
13
|
+
result: TestResult;
|
|
14
|
+
}
|
|
15
|
+
/** SKIPPED: tests were found, every one was skipped, so nothing passed or failed. */
|
|
16
|
+
export type TestResult = 'PASSED' | 'FAILED' | 'IMPROVED' | 'DEGRADED' | 'SKIPPED';
|
|
17
|
+
/**
|
|
18
|
+
* Parse Jest output to extract test results
|
|
19
|
+
*
|
|
20
|
+
* Jest output formats:
|
|
21
|
+
* - "Tests: 1 failed, 172 passed, 173 total"
|
|
22
|
+
* - "Tests: 173 passed, 173 total"
|
|
23
|
+
* - "Test Suites: 2 failed, 16 passed, 18 total"
|
|
24
|
+
* - "Tests: 9 skipped, 799 passed, 808 total" (with padding)
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseJestOutput(output: string): TestResults | null;
|
|
27
|
+
/**
|
|
28
|
+
* Example Jest outputs for testing:
|
|
29
|
+
*
|
|
30
|
+
* All passing:
|
|
31
|
+
* "Tests: 173 passed, 173 total"
|
|
32
|
+
*
|
|
33
|
+
* Some failing:
|
|
34
|
+
* "Tests: 1 failed, 172 passed, 173 total"
|
|
35
|
+
*
|
|
36
|
+
* With skipped:
|
|
37
|
+
* "Tests: 1 failed, 2 skipped, 170 passed, 173 total"
|
|
38
|
+
*
|
|
39
|
+
* With padding (CI):
|
|
40
|
+
* "Tests: 9 skipped, 799 passed, 808 total"
|
|
41
|
+
*/
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Jest output parser
|
|
4
|
+
*
|
|
5
|
+
* Extracts test counts from Jest CLI output
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.parseJestOutput = parseJestOutput;
|
|
9
|
+
/**
|
|
10
|
+
* Parse Jest output to extract test results
|
|
11
|
+
*
|
|
12
|
+
* Jest output formats:
|
|
13
|
+
* - "Tests: 1 failed, 172 passed, 173 total"
|
|
14
|
+
* - "Tests: 173 passed, 173 total"
|
|
15
|
+
* - "Test Suites: 2 failed, 16 passed, 18 total"
|
|
16
|
+
* - "Tests: 9 skipped, 799 passed, 808 total" (with padding)
|
|
17
|
+
*/
|
|
18
|
+
function parseJestOutput(output) {
|
|
19
|
+
// Strip ANSI color codes and other control characters
|
|
20
|
+
// eslint-disable-next-line no-control-regex
|
|
21
|
+
let cleanOutput = output.replace(/\x1b\[[0-9;]*m/g, '');
|
|
22
|
+
// Also strip carriage returns and normalize line endings
|
|
23
|
+
cleanOutput = cleanOutput.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
24
|
+
// Find the Jest test summary line
|
|
25
|
+
// CRITICAL: Must match "Tests:" line that contains "total" to avoid matching
|
|
26
|
+
// test descriptions like "Brake Tests: Critical dogfooding scenarios"
|
|
27
|
+
const testSummaryPattern = /Tests:\s+(.+?\d+\s+total)/im;
|
|
28
|
+
const testLineMatch = cleanOutput.match(testSummaryPattern);
|
|
29
|
+
if (!testLineMatch || !testLineMatch[1]) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const testLine = testLineMatch[1];
|
|
33
|
+
// Extract counts using flexible patterns
|
|
34
|
+
let total = 0;
|
|
35
|
+
let passed = 0;
|
|
36
|
+
let failed = 0;
|
|
37
|
+
let skipped = 0;
|
|
38
|
+
// Parse numbers - use global search on the whole output near the Tests: line
|
|
39
|
+
const totalMatch = testLine.match(/(\d+)\s+total/i);
|
|
40
|
+
if (totalMatch) {
|
|
41
|
+
total = parseInt(totalMatch[1], 10);
|
|
42
|
+
}
|
|
43
|
+
const passedMatch = testLine.match(/(\d+)\s+passed/i);
|
|
44
|
+
if (passedMatch) {
|
|
45
|
+
passed = parseInt(passedMatch[1], 10);
|
|
46
|
+
}
|
|
47
|
+
const failedMatch = testLine.match(/(\d+)\s+failed/i);
|
|
48
|
+
if (failedMatch) {
|
|
49
|
+
failed = parseInt(failedMatch[1], 10);
|
|
50
|
+
}
|
|
51
|
+
const skippedMatch = testLine.match(/(\d+)\s+skipped/i);
|
|
52
|
+
if (skippedMatch) {
|
|
53
|
+
skipped = parseInt(skippedMatch[1], 10);
|
|
54
|
+
}
|
|
55
|
+
// Validate
|
|
56
|
+
if (total === 0) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
// Determine result
|
|
60
|
+
let result = 'PASSED';
|
|
61
|
+
if (failed > 0) {
|
|
62
|
+
result = 'FAILED';
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
total,
|
|
66
|
+
passed,
|
|
67
|
+
failed,
|
|
68
|
+
skipped: skipped > 0 ? skipped : undefined,
|
|
69
|
+
result,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Example Jest outputs for testing:
|
|
74
|
+
*
|
|
75
|
+
* All passing:
|
|
76
|
+
* "Tests: 173 passed, 173 total"
|
|
77
|
+
*
|
|
78
|
+
* Some failing:
|
|
79
|
+
* "Tests: 1 failed, 172 passed, 173 total"
|
|
80
|
+
*
|
|
81
|
+
* With skipped:
|
|
82
|
+
* "Tests: 1 failed, 2 skipped, 170 passed, 173 total"
|
|
83
|
+
*
|
|
84
|
+
* With padding (CI):
|
|
85
|
+
* "Tests: 9 skipped, 799 passed, 808 total"
|
|
86
|
+
*/
|
|
87
|
+
//# sourceMappingURL=jest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.js","sourceRoot":"","sources":["../../src/parsers/jest.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAwBH,0CAgEC;AAzED;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAC,MAAc;IAC5C,sDAAsD;IACtD,4CAA4C;IAC5C,IAAI,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACxD,yDAAyD;IACzD,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEtE,kCAAkC;IAClC,6EAA6E;IAC7E,sEAAsE;IACtE,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;IACzD,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAE5D,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAElC,yCAAyC;IACzC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,6EAA6E;IAC7E,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACpD,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACtD,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACtD,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACxD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW;IACX,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mBAAmB;IACnB,IAAI,MAAM,GAAe,QAAQ,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,GAAG,QAAQ,CAAC;IACpB,CAAC;IAED,OAAO;QACL,KAAK;QACL,MAAM;QACN,MAAM;QACN,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAC1C,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JUnit XML parser
|
|
3
|
+
*
|
|
4
|
+
* Extracts test counts from a JUnit XML report — the common format nearly every
|
|
5
|
+
* test runner can write: pytest (--junitxml), cargo (nextest, cargo2junit), Go
|
|
6
|
+
* (go-junit-report, gotestsum), Maven/Gradle, .NET, PHPUnit, Jest (jest-junit).
|
|
7
|
+
*/
|
|
8
|
+
import { TestResults } from './jest';
|
|
9
|
+
/**
|
|
10
|
+
* Parse a JUnit XML report to extract test results
|
|
11
|
+
*
|
|
12
|
+
* Handles:
|
|
13
|
+
* - a <testsuites> root that carries the totals (gotestsum, Maven)
|
|
14
|
+
* - a <testsuites> root without totals, around counted <testsuite>s (pytest)
|
|
15
|
+
* - a single <testsuite> root
|
|
16
|
+
* - nested <testsuite>s, or <testcase>s outside any suite: the <testcase>s are
|
|
17
|
+
* counted. Writers disagree on what an outer suite's `tests` means (node:test
|
|
18
|
+
* counts a nested describe as one test; PHPUnit counts every test inside it),
|
|
19
|
+
* and node:test puts top-level tests beside its suites, under the root
|
|
20
|
+
* - suites with no counts at all (the <testcase> elements are counted instead)
|
|
21
|
+
*
|
|
22
|
+
* failures + errors count as failed; skipped + disabled count as skipped.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseJunitOutput(output: string): TestResults | null;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* JUnit XML parser
|
|
4
|
+
*
|
|
5
|
+
* Extracts test counts from a JUnit XML report — the common format nearly every
|
|
6
|
+
* test runner can write: pytest (--junitxml), cargo (nextest, cargo2junit), Go
|
|
7
|
+
* (go-junit-report, gotestsum), Maven/Gradle, .NET, PHPUnit, Jest (jest-junit).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.parseJunitOutput = parseJunitOutput;
|
|
11
|
+
const skipped_names_1 = require("../skipped-names");
|
|
12
|
+
const SUITE_TAG = /<(\/?)testsuite\b([^>]*?)(\/?)>/g;
|
|
13
|
+
/** Read one numeric attribute; undefined when the attribute is absent. */
|
|
14
|
+
function attr(attrs, name) {
|
|
15
|
+
const match = attrs.match(new RegExp(`\\b${name}\\s*=\\s*["'](\\d+)["']`));
|
|
16
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
17
|
+
}
|
|
18
|
+
/** Counts from a <testsuite> or <testsuites> attribute list, or null without a `tests` count. */
|
|
19
|
+
function countsFromAttrs(attrs) {
|
|
20
|
+
const tests = attr(attrs, 'tests');
|
|
21
|
+
if (tests === undefined)
|
|
22
|
+
return null;
|
|
23
|
+
return {
|
|
24
|
+
tests,
|
|
25
|
+
failed: (attr(attrs, 'failures') ?? 0) + (attr(attrs, 'errors') ?? 0),
|
|
26
|
+
skipped: (attr(attrs, 'skipped') ?? 0) + (attr(attrs, 'disabled') ?? 0),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Fallback when suites carry no counts: walk the <testcase> elements themselves. */
|
|
30
|
+
function countsFromTestcases(xml) {
|
|
31
|
+
const counts = { tests: 0, failed: 0, skipped: 0 };
|
|
32
|
+
const testcase = /<testcase\b[^>]*?(?:\/>|>([\s\S]*?)<\/testcase>)/g;
|
|
33
|
+
let match;
|
|
34
|
+
while ((match = testcase.exec(xml)) !== null) {
|
|
35
|
+
counts.tests++;
|
|
36
|
+
const body = match[1] ?? '';
|
|
37
|
+
if (/<(failure|error)\b/.test(body))
|
|
38
|
+
counts.failed++;
|
|
39
|
+
else if (/<skipped\b/.test(body))
|
|
40
|
+
counts.skipped++;
|
|
41
|
+
}
|
|
42
|
+
return counts;
|
|
43
|
+
}
|
|
44
|
+
/** One string attribute of a tag, entities decoded; undefined when absent. */
|
|
45
|
+
function textAttr(attrs, name) {
|
|
46
|
+
const match = attrs.match(new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`));
|
|
47
|
+
return match ? (0, skipped_names_1.decodeXmlEntities)(match[1] ?? match[2] ?? '') : undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Names of the skipped <testcase>s: "classname > name", or just the name when
|
|
51
|
+
* the class adds nothing (jest-junit repeats the name as the class).
|
|
52
|
+
*/
|
|
53
|
+
function skippedNamesFromTestcases(xml) {
|
|
54
|
+
const names = [];
|
|
55
|
+
const testcase = /<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g;
|
|
56
|
+
let match;
|
|
57
|
+
while ((match = testcase.exec(xml)) !== null) {
|
|
58
|
+
const body = match[2] ?? '';
|
|
59
|
+
if (/<(failure|error)\b/.test(body) || !/<skipped\b/.test(body))
|
|
60
|
+
continue;
|
|
61
|
+
const name = textAttr(match[1], 'name') ?? '';
|
|
62
|
+
const cls = textAttr(match[1], 'classname');
|
|
63
|
+
names.push(cls && cls !== name && !name.includes(cls) ? `${cls} > ${name}` : name);
|
|
64
|
+
}
|
|
65
|
+
return names;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parse a JUnit XML report to extract test results
|
|
69
|
+
*
|
|
70
|
+
* Handles:
|
|
71
|
+
* - a <testsuites> root that carries the totals (gotestsum, Maven)
|
|
72
|
+
* - a <testsuites> root without totals, around counted <testsuite>s (pytest)
|
|
73
|
+
* - a single <testsuite> root
|
|
74
|
+
* - nested <testsuite>s, or <testcase>s outside any suite: the <testcase>s are
|
|
75
|
+
* counted. Writers disagree on what an outer suite's `tests` means (node:test
|
|
76
|
+
* counts a nested describe as one test; PHPUnit counts every test inside it),
|
|
77
|
+
* and node:test puts top-level tests beside its suites, under the root
|
|
78
|
+
* - suites with no counts at all (the <testcase> elements are counted instead)
|
|
79
|
+
*
|
|
80
|
+
* failures + errors count as failed; skipped + disabled count as skipped.
|
|
81
|
+
*/
|
|
82
|
+
function parseJunitOutput(output) {
|
|
83
|
+
const xml = output.replace(/<!--[\s\S]*?-->/g, '');
|
|
84
|
+
if (!/<testsuites?\b/.test(xml))
|
|
85
|
+
return null;
|
|
86
|
+
let counts = null;
|
|
87
|
+
const root = xml.match(/<testsuites\b([^>]*)>/);
|
|
88
|
+
if (root)
|
|
89
|
+
counts = countsFromAttrs(root[1]);
|
|
90
|
+
if (!counts) {
|
|
91
|
+
// Sum the outermost <testsuite>s; a suite without counts sends us to the testcases.
|
|
92
|
+
let depth = 0;
|
|
93
|
+
let summed = { tests: 0, failed: 0, skipped: 0 };
|
|
94
|
+
let seen = 0;
|
|
95
|
+
let nested = false;
|
|
96
|
+
let match;
|
|
97
|
+
SUITE_TAG.lastIndex = 0;
|
|
98
|
+
while ((match = SUITE_TAG.exec(xml)) !== null) {
|
|
99
|
+
const [, closing, attrs, selfClosing] = match;
|
|
100
|
+
if (closing) {
|
|
101
|
+
depth--;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (depth > 0)
|
|
105
|
+
nested = true;
|
|
106
|
+
if (depth === 0 && summed) {
|
|
107
|
+
seen++;
|
|
108
|
+
const suite = countsFromAttrs(attrs);
|
|
109
|
+
if (suite) {
|
|
110
|
+
summed.tests += suite.tests;
|
|
111
|
+
summed.failed += suite.failed;
|
|
112
|
+
summed.skipped += suite.skipped;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
summed = null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!selfClosing)
|
|
119
|
+
depth++;
|
|
120
|
+
}
|
|
121
|
+
const testcases = countsFromTestcases(xml);
|
|
122
|
+
// More testcases than the suites count means tests sit outside them.
|
|
123
|
+
const useSuites = seen > 0 && summed && (testcases.tests === 0 || (!nested && testcases.tests <= summed.tests));
|
|
124
|
+
counts = useSuites && summed ? summed : testcases;
|
|
125
|
+
}
|
|
126
|
+
if (counts.tests === 0)
|
|
127
|
+
return null;
|
|
128
|
+
// Some writers leave `skipped` off their counts (gotestsum's <testsuites> root
|
|
129
|
+
// has tests and failures only), which would count every skip as a pass. The
|
|
130
|
+
// <skipped> testcases are the truth then.
|
|
131
|
+
if (counts.skipped === 0) {
|
|
132
|
+
counts.skipped = Math.min(countsFromTestcases(xml).skipped, counts.tests - counts.failed);
|
|
133
|
+
}
|
|
134
|
+
const passed = Math.max(0, counts.tests - counts.failed - counts.skipped);
|
|
135
|
+
return {
|
|
136
|
+
total: counts.tests,
|
|
137
|
+
passed,
|
|
138
|
+
failed: counts.failed,
|
|
139
|
+
skipped: counts.skipped > 0 ? counts.skipped : undefined,
|
|
140
|
+
skippedNames: counts.skipped > 0 ? skippedNamesFromTestcases(xml) : undefined,
|
|
141
|
+
result: counts.failed > 0 ? 'FAILED' : 'PASSED',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=junit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junit.js","sourceRoot":"","sources":["../../src/parsers/junit.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAmFH,4CA6DC;AA7ID,oDAAqD;AAErD,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAErD,0EAA0E;AAC1E,SAAS,IAAI,CAAC,KAAa,EAAE,IAAY;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,IAAI,yBAAyB,CAAC,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC;AAQD,iGAAiG;AACjG,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,OAAO;QACL,KAAK;QACL,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;KACxE,CAAC;A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AC,CAAC,CAAC,SAAS,CAAC;IACpD,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpC,+EAA+E;IAC/E,4EAA4E;IAC5E,0CAA0C;IAC1C,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1E,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM;QACN,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QACxD,YAAY,EAAE,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7E,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vitest output parser
|
|
3
|
+
*
|
|
4
|
+
* Extracts test counts from Vitest CLI output
|
|
5
|
+
*/
|
|
6
|
+
import { TestResults } from './jest';
|
|
7
|
+
/**
|
|
8
|
+
* Parse Vitest output to extract test results
|
|
9
|
+
*
|
|
10
|
+
* Vitest output formats:
|
|
11
|
+
* - " Tests 8 passed (8)"
|
|
12
|
+
* - " Tests 2 failed | 6 passed (8)"
|
|
13
|
+
* - " Tests 1 skipped | 7 passed (8)"
|
|
14
|
+
* - " Tests 1 failed | 2 skipped | 5 passed (8)"
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseVitestOutput(output: string): TestResults | null;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vitest output parser
|
|
4
|
+
*
|
|
5
|
+
* Extracts test counts from Vitest CLI output
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.parseVitestOutput = parseVitestOutput;
|
|
9
|
+
/**
|
|
10
|
+
* Parse Vitest output to extract test results
|
|
11
|
+
*
|
|
12
|
+
* Vitest output formats:
|
|
13
|
+
* - " Tests 8 passed (8)"
|
|
14
|
+
* - " Tests 2 failed | 6 passed (8)"
|
|
15
|
+
* - " Tests 1 skipped | 7 passed (8)"
|
|
16
|
+
* - " Tests 1 failed | 2 skipped | 5 passed (8)"
|
|
17
|
+
*/
|
|
18
|
+
function parseVitestOutput(output) {
|
|
19
|
+
// Strip ANSI color codes
|
|
20
|
+
// eslint-disable-next-line no-control-regex
|
|
21
|
+
let cleanOutput = output.replace(/\x1b\[[0-9;]*m/g, '');
|
|
22
|
+
cleanOutput = cleanOutput.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
23
|
+
// Vitest summary pattern: " Tests ... (N)" where N is total in parens
|
|
24
|
+
const testSummaryPattern = /^\s*Tests\s+(.+?\(\d+\))/m;
|
|
25
|
+
const testLineMatch = cleanOutput.match(testSummaryPattern);
|
|
26
|
+
if (!testLineMatch || !testLineMatch[1]) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const testLine = testLineMatch[1];
|
|
30
|
+
// Extract total from parentheses at end
|
|
31
|
+
const totalMatch = testLine.match(/\((\d+)\)\s*$/);
|
|
32
|
+
if (!totalMatch)
|
|
33
|
+
return null;
|
|
34
|
+
const total = parseInt(totalMatch[1], 10);
|
|
35
|
+
if (total === 0)
|
|
36
|
+
return null;
|
|
37
|
+
let passed = 0;
|
|
38
|
+
let failed = 0;
|
|
39
|
+
let skipped = 0;
|
|
40
|
+
const passedMatch = testLine.match(/(\d+)\s+passed/i);
|
|
41
|
+
if (passedMatch)
|
|
42
|
+
passed = parseInt(passedMatch[1], 10);
|
|
43
|
+
const failedMatch = testLine.match(/(\d+)\s+failed/i);
|
|
44
|
+
if (failedMatch)
|
|
45
|
+
failed = parseInt(failedMatch[1], 10);
|
|
46
|
+
const skippedMatch = testLine.match(/(\d+)\s+skipped/i);
|
|
47
|
+
if (skippedMatch)
|
|
48
|
+
skipped = parseInt(skippedMatch[1], 10);
|
|
49
|
+
const todoMatch = testLine.match(/(\d+)\s+todo/i);
|
|
50
|
+
if (todoMatch)
|
|
51
|
+
skipped += parseInt(todoMatch[1], 10);
|
|
52
|
+
let result = failed > 0 ? 'FAILED' : 'PASSED';
|
|
53
|
+
return {
|
|
54
|
+
total,
|
|
55
|
+
passed,
|
|
56
|
+
failed,
|
|
57
|
+
skipped: skipped > 0 ? skipped : undefined,
|
|
58
|
+
result,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/parsers/vitest.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAaH,8CA+CC;AAxDD;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAAC,MAAc;IAC9C,yBAAyB;IACzB,4CAA4C;IAC5C,IAAI,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACxD,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEtE,uEAAuE;IACvE,M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AS;QAAE,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAErD,IAAI,MAAM,GAAwB,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEnE,OAAO;QACL,KAAK;QACL,MAAM;QACN,MAAM;QACN,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAC1C,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WJTTC output parser
|
|
3
|
+
*
|
|
4
|
+
* Extracts test counts from the FAF / pc-ai WJTTC bar runner
|
|
5
|
+
* (tests/wjttc/run-wjttc.mjs and sibling suite runners).
|
|
6
|
+
*
|
|
7
|
+
* Two shapes:
|
|
8
|
+
*
|
|
9
|
+
* 1) Human log (default):
|
|
10
|
+
* ```
|
|
11
|
+
* pc-ai WJTTC
|
|
12
|
+
* ----------
|
|
13
|
+
* PASS VAL-01 valid-simple portfolio accepts
|
|
14
|
+
* FAIL OPT-01 …
|
|
15
|
+
* ----------
|
|
16
|
+
* 31/33 passed
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* 2) Machine JSON (`--json`):
|
|
20
|
+
* ```
|
|
21
|
+
* {
|
|
22
|
+
* "suite": "pc-ai-wjttc",
|
|
23
|
+
* "total": 33,
|
|
24
|
+
* "passed": 31,
|
|
25
|
+
* "failed": 2,
|
|
26
|
+
* "results": [ … ]
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Anchors are WJTTC-specific so this never false-matches Jest/Vitest/Bun.
|
|
31
|
+
* Prefer JSON when both appear in a teed stream (structured totals win).
|
|
32
|
+
*/
|
|
33
|
+
import { TestResults } from './jest';
|
|
34
|
+
/**
|
|
35
|
+
* Parse WJTTC (pc-ai bar) output to TestResults, or null if not WJTTC.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseWjttcOutput(output: string): TestResults | null;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WJTTC output parser
|
|
4
|
+
*
|
|
5
|
+
* Extracts test counts from the FAF / pc-ai WJTTC bar runner
|
|
6
|
+
* (tests/wjttc/run-wjttc.mjs and sibling suite runners).
|
|
7
|
+
*
|
|
8
|
+
* Two shapes:
|
|
9
|
+
*
|
|
10
|
+
* 1) Human log (default):
|
|
11
|
+
* ```
|
|
12
|
+
* pc-ai WJTTC
|
|
13
|
+
* ----------
|
|
14
|
+
* PASS VAL-01 valid-simple portfolio accepts
|
|
15
|
+
* FAIL OPT-01 …
|
|
16
|
+
* ----------
|
|
17
|
+
* 31/33 passed
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* 2) Machine JSON (`--json`):
|
|
21
|
+
* ```
|
|
22
|
+
* {
|
|
23
|
+
* "suite": "pc-ai-wjttc",
|
|
24
|
+
* "total": 33,
|
|
25
|
+
* "passed": 31,
|
|
26
|
+
* "failed": 2,
|
|
27
|
+
* "results": [ … ]
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Anchors are WJTTC-specific so this never false-matches Jest/Vitest/Bun.
|
|
32
|
+
* Prefer JSON when both appear in a teed stream (structured totals win).
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.parseWjttcOutput = parseWjttcOutput;
|
|
36
|
+
function stripAnsi(output) {
|
|
37
|
+
// eslint-disable-next-line no-control-regex
|
|
38
|
+
return output
|
|
39
|
+
.replace(/\x1b\[[0-9;]*m/g, '')
|
|
40
|
+
.replace(/\r\n/g, '\n')
|
|
41
|
+
.replace(/\r/g, '\n');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Try to parse a WJTTC --json summary object from output.
|
|
45
|
+
* Handles pure JSON or JSON embedded after build noise in a tee file.
|
|
46
|
+
*/
|
|
47
|
+
function parseJsonSuite(clean) {
|
|
48
|
+
// Prefer a top-level object that names the suite.
|
|
49
|
+
const candidates = [];
|
|
50
|
+
const trimmed = clean.trim();
|
|
51
|
+
if (trimmed.startsWith('{')) {
|
|
52
|
+
candidates.push(trimmed);
|
|
53
|
+
}
|
|
54
|
+
// Last {...} block often is the suite when logs precede JSON.
|
|
55
|
+
const lastBrace = clean.lastIndexOf('{');
|
|
56
|
+
if (lastBrace !== -1) {
|
|
57
|
+
candidates.push(clean.slice(lastBrace));
|
|
58
|
+
}
|
|
59
|
+
for (const raw of candidates) {
|
|
60
|
+
try {
|
|
61
|
+
const body = JSON.parse(raw);
|
|
62
|
+
if (!body || typeof body !== 'object')
|
|
63
|
+
continue;
|
|
64
|
+
if (body.suite !== 'pc-ai-wjttc')
|
|
65
|
+
continue;
|
|
66
|
+
const total = Number(body.total);
|
|
67
|
+
const passed = Number(body.passed);
|
|
68
|
+
const failed = Number(body.failed);
|
|
69
|
+
if (!Number.isFinite(total) || total <= 0)
|
|
70
|
+
continue;
|
|
71
|
+
if (!Number.isFinite(passed) || !Number.isFinite(failed))
|
|
72
|
+
continue;
|
|
73
|
+
// Prefer explicit fields; fall back to results[] length if needed.
|
|
74
|
+
let p = passed;
|
|
75
|
+
let f = failed;
|
|
76
|
+
let t = total;
|
|
77
|
+
if (Array.isArray(body.results) && body.results.length > 0) {
|
|
78
|
+
const fromRows = body.results.length;
|
|
79
|
+
if (t !== fromRows && fromRows > 0) {
|
|
80
|
+
// Trust results array as the executed set (partition honesty).
|
|
81
|
+
t = fromRows;
|
|
82
|
+
p = body.results.filter((r) => r && r.ok === true).length;
|
|
83
|
+
f = t - p;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
total: t,
|
|
88
|
+
passed: p,
|
|
89
|
+
failed: f,
|
|
90
|
+
result: f > 0 ? 'FAILED' : 'PASSED',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// try next candidate
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Human WJTTC log: header + optional PASS/FAIL lines + "N/N passed".
|
|
101
|
+
*/
|
|
102
|
+
function parseHumanLog(clean) {
|
|
103
|
+
// Require the suite banner so we do not steal "12/12 passed" from other tools.
|
|
104
|
+
if (!/pc-ai\s+WJTTC/i.test(clean)) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const summary = clean.match(/(\d+)\s*\/\s*(\d+)\s+passed\b/i);
|
|
108
|
+
if (!summary)
|
|
109
|
+
return null;
|
|
110
|
+
const passedFromSummary = parseInt(summary[1], 10);
|
|
111
|
+
const totalFromSummary = parseInt(summary[2], 10);
|
|
112
|
+
if (totalFromSummary <= 0)
|
|
113
|
+
return null;
|
|
114
|
+
// Cross-check with PASS/FAIL lines when present (stronger than summary alone).
|
|
115
|
+
const passLines = clean.match(/^PASS\s+\S+/gm);
|
|
116
|
+
const failLines = clean.match(/^FAIL\s+\S+/gm);
|
|
117
|
+
const linePassed = passLines ? passLines.length : -1;
|
|
118
|
+
const lineFailed = failLines ? failLines.length : -1;
|
|
119
|
+
let total = totalFromSummary;
|
|
120
|
+
let passed = passedFromSummary;
|
|
121
|
+
let failed = total - passed;
|
|
122
|
+
if (linePassed >= 0 && lineFailed >= 0) {
|
|
123
|
+
const lineTotal = linePassed + lineFailed;
|
|
124
|
+
if (lineTotal === totalFromSummary) {
|
|
125
|
+
passed = linePassed;
|
|
126
|
+
failed = lineFailed;
|
|
127
|
+
total = lineTotal;
|
|
128
|
+
}
|
|
129
|
+
// If lines disagree with summary, still use summary (runner is source of truth)
|
|
130
|
+
// but failed must be non-negative.
|
|
131
|
+
if (failed < 0)
|
|
132
|
+
failed = 0;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
total,
|
|
136
|
+
passed,
|
|
137
|
+
failed,
|
|
138
|
+
result: failed > 0 ? 'FAILED' : 'PASSED',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Parse WJTTC (pc-ai bar) output to TestResults, or null if not WJTTC.
|
|
143
|
+
*/
|
|
144
|
+
function parseWjttcOutput(output) {
|
|
145
|
+
const clean = stripAnsi(output);
|
|
146
|
+
// JSON first — structured totals when --json was used.
|
|
147
|
+
const fromJson = parseJsonSuite(clean);
|
|
148
|
+
if (fromJson)
|
|
149
|
+
return fromJson;
|
|
150
|
+
return parseHumanLog(clean);
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=wjttc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wjttc.js","sourceRoot":"","sources":["../../src/parsers/wjttc.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAwHH,4CAQC;AA5HD,SAAS,SAAS,CAAC,MAAc;IAC/B,4CAA4C;IAC5C,OAAO,MAAM;SACV,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAC9B,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,KAAa;IACnC,kDAAkD;IAClD,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,8DAA8D;IAC9D,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,UAA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