1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Fix lcov report when test module missing coverage.

We don't report branch coverage on test modules (e.g. test/src/module/common/errorTest.c) but the code that excluded branch coverage from the test module would also exclude it from all core modules if the test module was included in the lcov report due to lack of function/line coverage.

Adjust the coverage code to only exclude branches during the extraction of test module coverage.
This commit is contained in:
David Steele 2020-03-20 09:16:38 -04:00
parent f6e9bb0819
commit 8af8029006

View File

@ -103,13 +103,13 @@ sub coverageExtract
my $strLCovConf = "${strTestResultCoveragePath}/raw/lcov.conf";
coverageLCovConfigGenerate($oStorage, $strLCovConf, $bSummary);
my $strLCovExeBase = "lcov --config-file=${strLCovConf}";
my $strLCovExe = "lcov --config-file=${strLCovConf}";
my $strLCovOut = "${strWorkUnitPath}/test.lcov";
my $strLCovOutTmp = "${strWorkUnitPath}/test.tmp.lcov";
executeTest(
(defined($strContainerImage) ? 'docker exec -i -u ' . TEST_USER . " ${strContainerImage} " : '') .
"${strLCovExeBase} --capture --directory=${strWorkUnitPath} --o=${strLCovOut}");
"${strLCovExe} --capture --directory=${strWorkUnitPath} --o=${strLCovOut}");
# Generate coverage report for each module
foreach my $strCoveredModule (@stryCoveredModule)
@ -124,14 +124,6 @@ sub coverageExtract
$bTest = true;
}
# Disable branch coverage for test files
my $strLCovExe = $strLCovExeBase;
if ($bTest)
{
$strLCovExe .= ' --rc lcov_branch_coverage=0';
}
# Generate lcov reports
my $strModulePath =
"${strWorkPath}/repo/" .
@ -141,7 +133,8 @@ sub coverageExtract
my $strLCovTotal = "${strWorkTmpPath}/all.lcov";
executeTest(
"${strLCovExe} --extract=${strLCovOut} */${strModuleName}.c --o=${strLCovOutTmp}");
"${strLCovExe}" . ($bTest ? ' --rc lcov_branch_coverage=0' : '') . " --extract=${strLCovOut} */${strModuleName}.c" .
" --o=${strLCovOutTmp}");
# Combine with prior run if there was one
if ($oStorage->exists($strLCovFile))
@ -150,8 +143,7 @@ sub coverageExtract
$strCoverage =~ s/^SF\:.*$/SF:$strModulePath\.c/mg;
$oStorage->put($strLCovOutTmp, $strCoverage);
executeTest(
"${strLCovExe} --add-tracefile=${strLCovOutTmp} --add-tracefile=${strLCovFile} --o=${strLCovOutTmp}");
executeTest("${strLCovExe} --add-tracefile=${strLCovOutTmp} --add-tracefile=${strLCovFile} --o=${strLCovOutTmp}");
}
# Update source file