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

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Runner/Runner.cpp
diff options
context:
space:
mode:
authorLeitwolf2026-11-14 16:46:04 +0300
committerGitHub2026-11-14 16:46:04 +0300
commit94a996a3ceafa9f0004ffc28a7de5c543cdb51c2 (patch)
treee8db06877788de36d3fd4166472c4511f0c0412a /src/Progmasoft/Runner/Runner.cpp
parent586a42e35788d269871dcadbed2ec59b6b8a9203 (diff)
parent5ad02bccfcb925df02d1273901b6e248d477c5fa (diff)
downloadcatch3-94a996a3ceafa9f0004ffc28a7de5c543cdb51c2.tar.gz
Merge pull request #39 from Progmasoft/feature/per-test-coverage
Keep per-test coverage with --coverage (roadmap step 4)
Diffstat (limited to 'src/Progmasoft/Runner/Runner.cpp')
-rw-r--r--src/Progmasoft/Runner/Runner.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/Progmasoft/Runner/Runner.cpp b/src/Progmasoft/Runner/Runner.cpp
index 77011322..5667f65e 100644
--- a/src/Progmasoft/Runner/Runner.cpp
+++ b/src/Progmasoft/Runner/Runner.cpp
@@ -22,6 +22,7 @@
#include <random>
#include <system_error>
+#include "CoverageReport.hpp"
#include "Analysis.hpp"
#include "Catalog.hpp"
#include "Console.hpp"
@@ -949,6 +950,17 @@ namespace Progmasoft::Catch3
}
}
+ if (!options.coverageDirectory.empty())
+ {
+ if (auto status = Runner::PrepareCoverageDirectory(
+ options.coverageDirectory);
+ !status)
+ {
+ PrintError(status.GetError().Message());
+ return Catch::UnspecifiedErrorExitCode;
+ }
+ }
+
const auto started = std::chrono::steady_clock::now();
RunResult run;
run.binary = programName;
@@ -983,6 +995,26 @@ namespace Progmasoft::Catch3
run.tests.push_back(std::move(kept));
}
run.notes = std::move(outcome.notes);
+ bool coverageFailed = false;
+ if (!options.coverageDirectory.empty())
+ {
+ auto coverage
+ = Runner::WriteCoverageReports(options.coverageDirectory,
+ run,
+ program.string(),
+ run.workers);
+ for (auto &note : coverage.notes)
+ {
+ run.notes.push_back(std::move(note));
+ }
+ // Like a report that could not be written, a coverage
+ // failure makes the run fail when its tests passed.
+ coverageFailed = !coverage.failures.empty();
+ for (auto &failure : coverage.failures)
+ {
+ run.notes.push_back(std::move(failure));
+ }
+ }
const bool anyFailure
= std::any_of(run.tests.begin(),
@@ -1003,7 +1035,8 @@ namespace Progmasoft::Catch3
Runner::Analyze(run, analysis);
console.RunEnded(run);
- const bool reportMissing = !WriteReports(options, run);
+ const bool reportMissing
+ = !WriteReports(options, run) || coverageFailed;
if (options.historyEnabled)
{
SaveHistory(historyFile,