Output Formats¶
trep supports four output modes selected with --output-format.
HTML (default)¶
The default output is a fully self-contained HTML file — a single .html with all styles and scripts inlined. No internet connection, CDN, or build step required to open it.
Report features:
- Grouped view (default): suites collapse/expand on click; each suite shows a pass/fail badge
- Flat view: toggle button; click-to-sort on all columns
- Live search: debounced 200 ms; matches suite name and test name simultaneously
- Filter buttons: All / Passed / Failed / Skipped
- Slow test highlighting: tests in the top 10% of duration in the current view are highlighted
- Console output: failures with captured stdout show a "Show Console Output" toggle
- File/line links: Google Test source locations rendered under the test name
- Pagination: 200 tests / 50 suites per page with a smart page-range widget
- Delta badges: when
--baselineis used, pass/fail/skip counts and coverage % show run-over-run changes
JSON¶
Flag: --output-format json
Structured JSON for dashboard ingestion, jq scripting, or CI metrics pipelines.
Test JSON schema¶
{
"generated_at": "2024-03-15T10:00:00Z",
"summary": {
"total": 42,
"passed": 40,
"failed": 1,
"skipped": 1,
"pass_pct": 95.2
},
"suites": [
{
"name": "CoreTests",
"cases": [
{ "name": "TestAdd", "status": "pass", "duration_ms": 12 },
{
"name": "TestDiv",
"status": "fail",
"duration_ms": 5,
"message": "expected 5, got 4",
"file": "core_test.go",
"line": 30
}
]
}
]
}
Coverage JSON schema¶
{
"generated_at": "2024-03-15T10:00:00Z",
"summary": {
"lines_pct": 84.2,
"lines_covered": 320,
"lines_total": 380,
"branch_pct": 71.0,
"branch_covered": 142,
"branch_total": 200,
"func_pct": 91.3,
"func_covered": 63,
"func_total": 69,
"file_count": 12
},
"files": [
{
"path": "src/parser.go",
"lines_pct": 68.4,
"lines_covered": 13,
"lines_total": 19,
"branch_pct": 75.0,
"branch_covered": 3,
"branch_total": 4
}
]
}
SARIF¶
Flag: --output-format sarif
Produces SARIF 2.1.0 for GitHub Advanced Security code scanning alerts.
# SARIF for failed tests
trep test --output-format sarif -o results.sarif junit.xml
# SARIF for coverage — flags files below 80%
trep cov --output-format sarif --threshold 80 -o cov.sarif coverage.out
Upload in a workflow step:
Behaviour:
- Test SARIF: each failing test case becomes a result with level
error. File and line info are included when the format provides them (e.g. Google Test XML). Passing and skipped tests are omitted. - Coverage SARIF: when
--thresholdis set, every file below the threshold becomes a result with levelwarning. When no threshold is set, an empty results array is produced (clearing any previous GHAS alerts).
CI annotations¶
Flag: --annotate
Emits annotation lines in the native format of the detected CI platform.
| Platform | Output |
|---|---|
| GitHub Actions (auto-detected) | ::error file=...,line=...::message |
| GitLab CI (auto-detected) | GL-CODE-QUALITY JSON to stdout |
| Manual override | --annotate-platform github or --annotate-platform gitlab |
Annotations appear as inline comments on the PR diff in both platforms.
Snapshots¶
Flags: --save-snapshot <file> / --baseline <file>
Persist a compact JSON snapshot of a run, then compare future runs against it to show delta badges in the HTML report.
# Save after a baseline run (e.g. on the main branch)
trep report --tests results.xml --cov cov.out \
--save-snapshot .trep/baseline.json
# Compare on PR branches
trep report --tests results.xml --cov cov.out \
--baseline .trep/baseline.json \
--baseline-label "main"
# → delta badges: "+2 pass / -1 fail / +3.2% cov"
The snapshot file is a small JSON document — commit it to your repository or store it as a CI artifact for cross-workflow comparisons.