1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Allow more tests to run outside of containers.

These tests required sudo to achieve complete coverage.

Add a new coverage exception, vm_covered, that applies to code that can only be covered in a container. When the test is run outside of a container code sections that require a container will be excluded with TEST_CONTAINER_REQUIRED and the coverage exception will be added to prevent a coverage error.

This does require marking up the core code with vm_covered, which in some modules (e.g. common/io/tls/client) can be extensive. It's possible that some of these tests can be rewritten to be less dependent on sudo but no attempt was made to do that here.

Only allow coverage summaries in a vm since coverage summaries outside a vm will not be complete, which was true even before this commit.
This commit is contained in:
David Steele
2020-05-09 09:17:33 -04:00
parent b4fc1804a8
commit 22d260ad53
11 changed files with 217 additions and 148 deletions
+11 -2
View File
@@ -35,12 +35,14 @@ sub coverageLCovConfigGenerate
{
my $oStorage = shift;
my $strOutFile = shift;
my $bContainer = shift;
my $bCoverageSummary = shift;
my $strBranchFilter =
'OBJECT_DEFINE_[A-Z0-9_]+\(|\s{4}[A-Z][A-Z0-9_]+\([^\?]*\)|\s{4}(ASSERT|assert|switch\s)\(|\{\+{0,1}' .
($bCoverageSummary ? 'uncoverable_branch' : 'uncover(ed|able)_branch');
my $strLineFilter = '\{\+{0,1}uncover' . ($bCoverageSummary ? 'able' : '(ed|able)') . '[^_]';
my $strLineFilter =
'\{\+{0,1}' . ($bCoverageSummary ? 'uncoverable' : '(uncover(ed|able)' . ($bContainer ? '' : '|vm_covered') . ')') . '[^_]';
my $strConfig =
"# LCOV Settings\n" .
@@ -80,6 +82,7 @@ sub coverageExtract
my $oStorage = shift;
my $strModule = shift;
my $strTest = shift;
my $bContainer = shift;
my $bSummary = shift;
my $strContainerImage = shift;
my $strWorkPath = shift;
@@ -87,6 +90,12 @@ sub coverageExtract
my $strWorkUnitPath = shift;
my $strTestResultCoveragePath = shift . '/coverage';
# Coverage summary must be run in a container
if ($bSummary && !$bContainer)
{
confess &log(ERROR, "coverage summary must be run on containers for full coverage");
}
# Generate a list of files to cover
my $hTestCoverage = (testDefModuleTest($strModule, $strTest))->{&TESTDEF_COVERAGE};
@@ -101,7 +110,7 @@ sub coverageExtract
# Generate coverage reports for the modules
my $strLCovConf = "${strTestResultCoveragePath}/raw/lcov.conf";
coverageLCovConfigGenerate($oStorage, $strLCovConf, $bSummary);
coverageLCovConfigGenerate($oStorage, $strLCovConf, $bContainer, $bSummary);
my $strLCovExe = "lcov --config-file=${strLCovConf}";
my $strLCovOut = "${strWorkUnitPath}/test.lcov";