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