You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-06 08:49:29 +02:00
Output coverage report on test failure in CI.
This allows analysis of coverage failures that only happen in CI. It is not ideal since the report needs to be copied from the log output into an HTML file where it can be viewed, but better than nothing.
This commit is contained in:
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@@ -64,6 +64,13 @@ jobs:
|
||||
- name: Run Test
|
||||
run: cd ${HOME?} && ${GITHUB_WORKSPACE?}/pgbackrest/test/ci.pl ${{matrix.param}} --param=build-max=2
|
||||
|
||||
# Output the coverage report on failure in case the failure was caused by lack of coverage. This is not ideal since the report
|
||||
# needs to be copied from the log output into an HTML file where it can be viewed, but better than nothing.
|
||||
- name: Coverage Report
|
||||
if: failure()
|
||||
run: |
|
||||
cat ${GITHUB_WORKSPACE?}/pgbackrest/test/result/coverage/coverage.html
|
||||
|
||||
# Basic tests on other architectures using emulation. The emulation is so slow that running all the unit tests would be too
|
||||
# expensive, but this at least shows that the build works and some of the more complex tests run. In particular, it is good to
|
||||
# test on one big-endian architecture to be sure that checksums are correct.
|
||||
|
||||
@@ -372,17 +372,29 @@ sub coverageValidateAndGenerate
|
||||
&log(INFO, "tested modules have full coverage");
|
||||
}
|
||||
|
||||
if ($bCoverageReport)
|
||||
# Always generate unified coverage report if there was missing coverage. This is useful for CI.
|
||||
if ($bCoverageReport || $result != 0)
|
||||
{
|
||||
&log(INFO, 'writing C coverage report');
|
||||
|
||||
if ($bCoverageReport)
|
||||
{
|
||||
executeTest(
|
||||
"genhtml ${strLCovFile} --config-file=${strTestResultCoveragePath}/raw/lcov.conf" .
|
||||
" --prefix=${strWorkPath}/repo" .
|
||||
" --output-directory=${strTestResultCoveragePath}/lcov");
|
||||
}
|
||||
|
||||
coverageGenerate(
|
||||
$oStorage, "${strWorkPath}/repo", "${strTestResultCoveragePath}/raw", "${strTestResultCoveragePath}/coverage.html");
|
||||
$oStorage, "${strWorkPath}/repo", "${strTestResultCoveragePath}/raw", "${strTestResultCoveragePath}/coverage.html",
|
||||
$bCoverageReport);
|
||||
}
|
||||
# Else output report status in the HTML
|
||||
else
|
||||
{
|
||||
$oStorage->put(
|
||||
"${strTestResultCoveragePath}/coverage.html",
|
||||
"<center>[ " . ($result == 0 ? "Coverage Complete" : "No Coverage Report") . " ]</center>");
|
||||
}
|
||||
|
||||
if ($bCoverageSummary)
|
||||
@@ -394,12 +406,6 @@ sub coverageValidateAndGenerate
|
||||
}
|
||||
}
|
||||
|
||||
# Remove coverage report when no coverage or no report to avoid confusion from looking at an old report
|
||||
if (!$bCoverageReport || !$oStorage->exists($strLCovFile))
|
||||
{
|
||||
executeTest("rm -rf ${strTestResultCoveragePath}");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -437,6 +443,7 @@ sub coverageGenerate
|
||||
my $strBasePath = shift;
|
||||
my $strCoveragePath = shift;
|
||||
my $strOutFile = shift;
|
||||
my $bCoverageReport = shift;
|
||||
|
||||
# Track missing coverage
|
||||
my $rhCoverage = {};
|
||||
@@ -446,6 +453,10 @@ sub coverageGenerate
|
||||
|
||||
foreach my $strFileCov (sort(keys(%{$rhManifest})))
|
||||
{
|
||||
# If a coverage report was not requested then skip coverage of test modules. If we are here it means there was missing
|
||||
# coverage on CI and we want to keep the report as small as possible.
|
||||
next if !$bCoverageReport && $strFileCov =~ /Test\.lcov$/;
|
||||
|
||||
if ($strFileCov =~ /\.lcov$/)
|
||||
{
|
||||
my $strCoverage = ${$oStorage->get("${strCoveragePath}/${strFileCov}")};
|
||||
|
||||
@@ -427,7 +427,9 @@ eval
|
||||
$oStorageTest->pathCreate(
|
||||
"${strBackRestBase}/test/result/coverage", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
||||
$oStorageBackRest->put(
|
||||
"${strBackRestBase}/test/result/coverage/coverage.html", "<center>[ Generating New Report ]</center>");
|
||||
"${strBackRestBase}/test/result/coverage/coverage.html",
|
||||
"<center>[ " . ($bNoCoverage ? "No Coverage Testing" : "Generating Coverage Report") . " ]</center>");
|
||||
executeTest("rm -rf ${strBackRestBase}/test/result/coverage/lcov");
|
||||
|
||||
# Copy C code for coverage tests
|
||||
if (vmCoverageC($strVm) && !$bDryRun)
|
||||
|
||||
Reference in New Issue
Block a user