Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/Progmasoft/CoverageFixture.cpp
diff options
context:
space:
mode:
authorLeitwolf112026-11-13 21:55:26 +0300
committerLeitwolf112026-11-13 21:55:26 +0300
commit454cca9b63991416f4d9bd1ca350f1ae14e278e7 (patch)
treed85cafe2ee3ca7c5a8897a3e0fdde844fb18c6f6 /tests/Progmasoft/CoverageFixture.cpp
parent55dab34729c14c9019b7062fccd11fc22372e805 (diff)
downloadcatch3-454cca9b63991416f4d9bd1ca350f1ae14e278e7.tar.gz
Fix the coverage review findings: branches, stale reports, exit status
- gcov is run with --branch-probabilities; without it the JSON has no branches, so GCC runs had none in coverage.json and coverage.lcov. - PrepareCoverageDirectory also removes coverage.json, coverage.lcov and coverage.profdata of an earlier run, so a run that writes no reports leaves none to be read as its own. - WriteCoverageReports returns notes and failures apart. A profile the tools cannot read or a report that cannot be written counts as a missing report and fails a run whose tests passed; no profiles or missing tools stay notes. The paths are announced only for the reports written. - ProfiledAttempt takes the last attempt whose profile exists, so a final retry or repeat that crashed before writing one no longer hides the coverage of the attempt before it. - The per-test llvm-profdata/llvm-cov and gcov runs use as many threads as the run had workers; results keep the order of the tests. Tests: earlier reports removed and no failure without profiles; an attempt without a profile gives way to an earlier one; the fixture gains a branch taken one way, checked in the combined LCOV for both LLVM and gcov. Amalgamation regenerated.
Diffstat (limited to 'tests/Progmasoft/CoverageFixture.cpp')
-rw-r--r--tests/Progmasoft/CoverageFixture.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/Progmasoft/CoverageFixture.cpp b/tests/Progmasoft/CoverageFixture.cpp
index a046a296..e728bbca 100644
--- a/tests/Progmasoft/CoverageFixture.cpp
+++ b/tests/Progmasoft/CoverageFixture.cpp
@@ -20,11 +20,22 @@ namespace
{
return value - 1; // coverage: subtract-one
}
+
+ int
+ NonNegative(int value)
+ {
+ if (value < 0) // coverage: branch
+ {
+ return 0;
+ }
+ return value;
+ }
} // namespace
TEST_CASE("Adds one", "[coverage]")
{
CHECK(AddOne(1) == 2);
+ CHECK(NonNegative(AddOne(1)) == 2);
}
TEST_CASE("Subtracts one", "[coverage]")