1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-17 01:12:23 +02:00

Add --no-coverage-report to test.pl to disable report generation.

There is no sense in generating detailed coverage reports in CI environments where they will never be seen. It takes time and format differences in some older versions can cause problems in the report generation code.

Note that missing coverage will still be reported on stdout and the test will fail.
This commit is contained in:
David Steele
2020-06-17 15:07:30 -04:00
parent ea984c4d3e
commit 417818dcca
3 changed files with 27 additions and 13 deletions

View File

@ -222,6 +222,7 @@ sub coverageValidateAndGenerate
{ {
my $oyTestRun = shift; my $oyTestRun = shift;
my $oStorage = shift; my $oStorage = shift;
my $bCoverageReport = shift;
my $bCoverageSummary = shift; my $bCoverageSummary = shift;
my $strWorkPath = shift; my $strWorkPath = shift;
my $strWorkTmpPath = shift; my $strWorkTmpPath = shift;
@ -287,17 +288,10 @@ sub coverageValidateAndGenerate
# Generate C coverage report # Generate C coverage report
#--------------------------------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------------------------------
&log(INFO, 'writing C coverage report');
my $strLCovFile = "${strWorkTmpPath}/all.lcov"; my $strLCovFile = "${strWorkTmpPath}/all.lcov";
if ($oStorage->exists($strLCovFile)) if ($oStorage->exists($strLCovFile))
{ {
executeTest(
"genhtml ${strLCovFile} --config-file=${strTestResultCoveragePath}/raw/lcov.conf" .
" --prefix=${strWorkPath}/repo" .
" --output-directory=${strTestResultCoveragePath}/lcov");
foreach my $strCodeModule (sort(keys(%{$hCoverageActual}))) foreach my $strCodeModule (sort(keys(%{$hCoverageActual})))
{ {
my $strCoverageFile = $strCodeModule; my $strCoverageFile = $strCodeModule;
@ -344,8 +338,23 @@ sub coverageValidateAndGenerate
} }
} }
if ($result == 0)
{
&log(INFO, "tested modules have full coverage");
}
if ($bCoverageReport)
{
&log(INFO, 'writing C coverage report');
executeTest(
"genhtml ${strLCovFile} --config-file=${strTestResultCoveragePath}/raw/lcov.conf" .
" --prefix=${strWorkPath}/repo" .
" --output-directory=${strTestResultCoveragePath}/lcov");
coverageGenerate( coverageGenerate(
$oStorage, "${strWorkPath}/repo", "${strTestResultCoveragePath}/raw", "${strTestResultCoveragePath}/coverage.html"); $oStorage, "${strWorkPath}/repo", "${strTestResultCoveragePath}/raw", "${strTestResultCoveragePath}/coverage.html");
}
if ($bCoverageSummary) if ($bCoverageSummary)
{ {
@ -355,9 +364,11 @@ sub coverageValidateAndGenerate
$oStorage, "${strTestResultCoveragePath}/raw", "${strTestResultSummaryPath}/metric-coverage-report.auto.xml"); $oStorage, "${strTestResultCoveragePath}/raw", "${strTestResultSummaryPath}/metric-coverage-report.auto.xml");
} }
} }
else
# 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}/test/tesult/coverage"); executeTest("rm -rf ${strTestResultCoveragePath}");
} }
return $result; return $result;

View File

@ -94,6 +94,7 @@ test.pl [options]
--expect --vm=co7 --pg-version=9.6 --log-force --expect --vm=co7 --pg-version=9.6 --log-force
--no-valgrind don't run valgrind on C unit tests (saves time) --no-valgrind don't run valgrind on C unit tests (saves time)
--no-coverage don't run coverage on C unit tests (saves time) --no-coverage don't run coverage on C unit tests (saves time)
--no-coverage-report run coverage but don't generate coverage report (saves time)
--no-optimize don't do compile optimization for C (saves compile time) --no-optimize don't do compile optimization for C (saves compile time)
--backtrace enable backtrace when available (adds stack trace line numbers -- very slow) --backtrace enable backtrace when available (adds stack trace line numbers -- very slow)
--profile generate profile info --profile generate profile info
@ -160,6 +161,7 @@ my $iBuildMax = 4;
my $bCoverageOnly = false; my $bCoverageOnly = false;
my $bCoverageSummary = false; my $bCoverageSummary = false;
my $bNoCoverage = false; my $bNoCoverage = false;
my $bNoCoverageReport = false;
my $bCOnly = false; my $bCOnly = false;
my $bContainerOnly = false; my $bContainerOnly = false;
my $bNoPerformance = false; my $bNoPerformance = false;
@ -213,6 +215,7 @@ GetOptions ('q|quiet' => \$bQuiet,
'coverage-only' => \$bCoverageOnly, 'coverage-only' => \$bCoverageOnly,
'coverage-summary' => \$bCoverageSummary, 'coverage-summary' => \$bCoverageSummary,
'no-coverage' => \$bNoCoverage, 'no-coverage' => \$bNoCoverage,
'no-coverage-report' => \$bNoCoverageReport,
'c-only' => \$bCOnly, 'c-only' => \$bCOnly,
'container-only' => \$bContainerOnly, 'container-only' => \$bContainerOnly,
'no-performance' => \$bNoPerformance, 'no-performance' => \$bNoPerformance,
@ -1157,7 +1160,7 @@ eval
if (vmCoverageC($strVm) && !$bNoCoverage && !$bDryRun && $iTestFail == 0) if (vmCoverageC($strVm) && !$bNoCoverage && !$bDryRun && $iTestFail == 0)
{ {
$iUncoveredCodeModuleTotal = coverageValidateAndGenerate( $iUncoveredCodeModuleTotal = coverageValidateAndGenerate(
$oyTestRun, $oStorageBackRest, $bCoverageSummary, $strTestPath, "${strTestPath}/temp", $oyTestRun, $oStorageBackRest, !$bNoCoverageReport, $bCoverageSummary, $strTestPath, "${strTestPath}/temp",
"${strBackRestBase}/test/result", "${strBackRestBase}/doc/xml/auto"); "${strBackRestBase}/test/result", "${strBackRestBase}/doc/xml/auto");
} }

View File

@ -219,7 +219,7 @@ eval
processBegin(($strVm eq VM_NONE ? "no container" : $strVm) . ' test'); processBegin(($strVm eq VM_NONE ? "no container" : $strVm) . ' test');
processExec( processExec(
"${strTestExe} --no-gen --vm-host=none --vm-max=2 --vm=${strVm}" . "${strTestExe} --no-gen --no-coverage-report --vm-host=none --vm-max=2 --vm=${strVm}" .
(@stryParam != 0 ? " --" . join(" --", @stryParam) : ''), (@stryParam != 0 ? " --" . join(" --", @stryParam) : ''),
{bShowOutputAsync => true, bOutLogOnError => false}); {bShowOutputAsync => true, bOutLogOnError => false});
processEnd(); processEnd();