You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Move raw coverage results to test/result/raw path.
These results were stored in the vagrant path along with a full copy of src. Instead store the raw coverage data in test/result/raw and change source references to the files that already exist in [test-path]/repo.
This commit is contained in:
@ -71,6 +71,7 @@ push @EXPORT, qw(coverageLCovConfigGenerate);
|
|||||||
sub coverageGenerate
|
sub coverageGenerate
|
||||||
{
|
{
|
||||||
my $oStorage = shift;
|
my $oStorage = shift;
|
||||||
|
my $strBasePath = shift;
|
||||||
my $strCoveragePath = shift;
|
my $strCoveragePath = shift;
|
||||||
my $strOutFile = shift;
|
my $strOutFile = shift;
|
||||||
|
|
||||||
@ -87,8 +88,7 @@ sub coverageGenerate
|
|||||||
my $strCoverage = ${$oStorage->get("${strCoveragePath}/${strFileCov}")};
|
my $strCoverage = ${$oStorage->get("${strCoveragePath}/${strFileCov}")};
|
||||||
|
|
||||||
# Show that the file is part of the coverage report even if there is no missing coverage
|
# Show that the file is part of the coverage report even if there is no missing coverage
|
||||||
my $strFile = substr($strFileCov, 0, length($strFileCov) - 5) . '.c';
|
my $strFile;
|
||||||
$rhCoverage->{$strFile} = undef;
|
|
||||||
|
|
||||||
my $iBranchLine = -1;
|
my $iBranchLine = -1;
|
||||||
my $iBranch = undef;
|
my $iBranch = undef;
|
||||||
@ -97,8 +97,14 @@ sub coverageGenerate
|
|||||||
|
|
||||||
foreach my $strLine (split("\n", $strCoverage))
|
foreach my $strLine (split("\n", $strCoverage))
|
||||||
{
|
{
|
||||||
|
# Get source file name
|
||||||
|
if ($strLine =~ /^SF\:/)
|
||||||
|
{
|
||||||
|
$strFile = substr($strLine, 3);
|
||||||
|
$rhCoverage->{$strFile} = undef;
|
||||||
|
}
|
||||||
# Check branch coverage
|
# Check branch coverage
|
||||||
if ($strLine =~ /^BRDA\:/)
|
elsif ($strLine =~ /^BRDA\:/)
|
||||||
{
|
{
|
||||||
my @stryData = split("\,", substr($strLine, 5));
|
my @stryData = split("\,", substr($strLine, 5));
|
||||||
|
|
||||||
@ -216,7 +222,7 @@ sub coverageGenerate
|
|||||||
{
|
{
|
||||||
if (defined($rhCoverage->{$strFile}{line}))
|
if (defined($rhCoverage->{$strFile}{line}))
|
||||||
{
|
{
|
||||||
my $strC = ${$oStorage->get("${strCoveragePath}/${strFile}")};
|
my $strC = ${$oStorage->get($strFile)};
|
||||||
my @stryC = split("\n", $strC);
|
my @stryC = split("\n", $strC);
|
||||||
|
|
||||||
foreach my $iLine (sort(keys(%{$rhCoverage->{$strFile}{line}})))
|
foreach my $iLine (sort(keys(%{$rhCoverage->{$strFile}{line}})))
|
||||||
@ -435,7 +441,7 @@ sub coverageGenerate
|
|||||||
foreach my $strFile (sort(keys(%{$rhCoverage})))
|
foreach my $strFile (sort(keys(%{$rhCoverage})))
|
||||||
{
|
{
|
||||||
my $oRow = $oTable->addNew(HTML_TR, 'list-table-row-' . (defined($rhCoverage->{$strFile}{line}) ? 'uncovered' : 'covered'));
|
my $oRow = $oTable->addNew(HTML_TR, 'list-table-row-' . (defined($rhCoverage->{$strFile}{line}) ? 'uncovered' : 'covered'));
|
||||||
$oRow->addNew(HTML_TD, 'list-table-row-file', {strContent => $strFile});
|
$oRow->addNew(HTML_TD, 'list-table-row-file', {strContent => substr($strFile, length($strBasePath) + 1)});
|
||||||
}
|
}
|
||||||
|
|
||||||
# Report on files that are missing coverage
|
# Report on files that are missing coverage
|
||||||
@ -446,14 +452,14 @@ sub coverageGenerate
|
|||||||
# Build the file report table
|
# Build the file report table
|
||||||
$oTable = $oHtml->bodyGet()->addNew(HTML_TABLE, 'report-table');
|
$oTable = $oHtml->bodyGet()->addNew(HTML_TABLE, 'report-table');
|
||||||
|
|
||||||
$oTable->addNew(HTML_DIV, 'report-table-caption', {strContent => "${strFile}"});
|
$oTable->addNew(HTML_DIV, 'report-table-caption', {strContent => substr($strFile, length($strBasePath) + 1)});
|
||||||
|
|
||||||
$oHeader = $oTable->addNew(HTML_TR, 'report-table-header');
|
$oHeader = $oTable->addNew(HTML_TR, 'report-table-header');
|
||||||
$oHeader->addNew(HTML_TH, 'report-table-header-line', {strContent => 'LINE'});
|
$oHeader->addNew(HTML_TH, 'report-table-header-line', {strContent => 'LINE'});
|
||||||
$oHeader->addNew(HTML_TH, 'report-table-header-branch', {strContent => 'BRANCH'});
|
$oHeader->addNew(HTML_TH, 'report-table-header-branch', {strContent => 'BRANCH'});
|
||||||
$oHeader->addNew(HTML_TH, 'report-table-header-code', {strContent => 'CODE'});
|
$oHeader->addNew(HTML_TH, 'report-table-header-code', {strContent => 'CODE'});
|
||||||
|
|
||||||
my $strC = ${$oStorage->get("${strCoveragePath}/${strFile}")};
|
my $strC = ${$oStorage->get($strFile)};
|
||||||
my @stryC = split("\n", $strC);
|
my @stryC = split("\n", $strC);
|
||||||
my $iLastLine = undef;
|
my $iLastLine = undef;
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ sub end
|
|||||||
"module/$self->{oTest}->{&TEST_MODULE}/" . testRunName($self->{oTest}->{&TEST_NAME}, false) . 'Test');
|
"module/$self->{oTest}->{&TEST_MODULE}/" . testRunName($self->{oTest}->{&TEST_NAME}, false) . 'Test');
|
||||||
|
|
||||||
# Generate coverage reports for the modules
|
# Generate coverage reports for the modules
|
||||||
my $strLCovConf = $self->{strBackRestBase} . '/test/.vagrant/code/lcov.conf';
|
my $strLCovConf = $self->{strBackRestBase} . '/test/result/coverage/raw/lcov.conf';
|
||||||
coverageLCovConfigGenerate($self->{oStorageTest}, $strLCovConf, $self->{bCoverageSummary});
|
coverageLCovConfigGenerate($self->{oStorageTest}, $strLCovConf, $self->{bCoverageSummary});
|
||||||
|
|
||||||
my $strLCovExeBase = "lcov --config-file=${strLCovConf}";
|
my $strLCovExeBase = "lcov --config-file=${strLCovConf}";
|
||||||
@ -659,9 +659,12 @@ sub end
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Generate lcov reports
|
# Generate lcov reports
|
||||||
my $strModulePath = $self->{strBackRestBase} . "/test/.vagrant/code/${strModuleOutName}";
|
my $strModulePath =
|
||||||
my $strLCovFile = "${strModulePath}.lcov";
|
$self->{strTestPath} . "/repo/" .
|
||||||
my $strLCovTotal = $self->{strBackRestBase} . "/test/.vagrant/code/all.lcov";
|
(${strModuleOutName} =~ /^test\// ?
|
||||||
|
'test/src/module/' . substr(${strModuleOutName}, 5) : "src/${strModuleOutName}");
|
||||||
|
my $strLCovFile = $self->{strBackRestBase} . "/test/result/coverage/raw/${strModuleOutName}.lcov";
|
||||||
|
my $strLCovTotal = $self->{strTestPath} . "/temp/all.lcov";
|
||||||
|
|
||||||
executeTest(
|
executeTest(
|
||||||
"${strLCovExe} --extract=${strLCovOut} */${strModuleName}.c --o=${strLCovOutTmp}");
|
"${strLCovExe} --extract=${strLCovOut} */${strModuleName}.c --o=${strLCovOutTmp}");
|
||||||
@ -709,7 +712,8 @@ sub end
|
|||||||
# Fix source file name
|
# Fix source file name
|
||||||
$strCoverage =~ s/^SF\:.*$/SF:$strModulePath\.c/mg;
|
$strCoverage =~ s/^SF\:.*$/SF:$strModulePath\.c/mg;
|
||||||
|
|
||||||
$self->{oStorageTest}->put($strLCovFile, $strCoverage);
|
$self->{oStorageTest}->put(
|
||||||
|
$self->{oStorageTest}->openWrite($strLCovFile, {bPathCreate => true}), $strCoverage);
|
||||||
|
|
||||||
if ($self->{oStorageTest}->exists($strLCovTotal))
|
if ($self->{oStorageTest}->exists($strLCovTotal))
|
||||||
{
|
{
|
||||||
|
29
test/test.pl
29
test/test.pl
@ -623,7 +623,7 @@ eval
|
|||||||
my $iTestFail = 0;
|
my $iTestFail = 0;
|
||||||
my $iTestRetry = 0;
|
my $iTestRetry = 0;
|
||||||
my $oyProcess = [];
|
my $oyProcess = [];
|
||||||
my $strCodePath = "${strBackRestBase}/test/.vagrant/code";
|
my $strCodePath = "${strBackRestBase}/test/result/coverage/raw";
|
||||||
|
|
||||||
if (!$bDryRun || $bVmOut)
|
if (!$bDryRun || $bVmOut)
|
||||||
{
|
{
|
||||||
@ -639,10 +639,11 @@ eval
|
|||||||
push(@{$oyProcess}, undef);
|
push(@{$oyProcess}, undef);
|
||||||
}
|
}
|
||||||
|
|
||||||
executeTest("rm -rf ${strTestPath}/test-* ${strTestPath}/data-*" . ($bDev ? '' : " ${strTestPath}/gcov-*"));
|
executeTest(
|
||||||
$oStorageTest->pathCreate($strTestPath, {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
"rm -rf ${strTestPath}/temp ${strTestPath}/test-* ${strTestPath}/data-*" . ($bDev ? '' : " ${strTestPath}/gcov-*"));
|
||||||
|
$oStorageTest->pathCreate("${strTestPath}/temp", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
||||||
|
|
||||||
# Remove old coverage dirs -- do it this way so the dirs stay open in finder/explorer, etc.
|
# Remove old lcov dirs -- do it this way so the dirs stay open in finder/explorer, etc.
|
||||||
executeTest("rm -rf ${strBackRestBase}/test/result/coverage/lcov/*");
|
executeTest("rm -rf ${strBackRestBase}/test/result/coverage/lcov/*");
|
||||||
|
|
||||||
# Overwrite the C coverage report so it will load but not show old coverage
|
# Overwrite the C coverage report so it will load but not show old coverage
|
||||||
@ -654,11 +655,8 @@ eval
|
|||||||
# Copy C code for coverage tests
|
# Copy C code for coverage tests
|
||||||
if (vmCoverageC($strVm) && !$bDryRun)
|
if (vmCoverageC($strVm) && !$bDryRun)
|
||||||
{
|
{
|
||||||
$oStorageTest->pathCreate("${strCodePath}/test", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
executeTest("rm -rf ${strBackRestBase}/test/result/coverage/raw/*");
|
||||||
|
$oStorageTest->pathCreate("${strCodePath}", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
||||||
executeTest(
|
|
||||||
"rsync -rt --delete --exclude=test ${strBackRestBase}/src/ ${strCodePath} && " .
|
|
||||||
"rsync -rt --delete ${strBackRestBase}/test/src/module/ ${strCodePath}/test");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1180,13 +1178,13 @@ eval
|
|||||||
{
|
{
|
||||||
&log(INFO, 'writing C coverage report');
|
&log(INFO, 'writing C coverage report');
|
||||||
|
|
||||||
my $strLCovFile = "${strBackRestBase}/test/.vagrant/code/all.lcov";
|
my $strLCovFile = "${strTestPath}/temp/all.lcov";
|
||||||
|
|
||||||
if ($oStorageBackRest->exists($strLCovFile))
|
if ($oStorageBackRest->exists($strLCovFile))
|
||||||
{
|
{
|
||||||
executeTest(
|
executeTest(
|
||||||
"genhtml ${strLCovFile} --config-file=${strBackRestBase}/test/.vagrant/code/lcov.conf" .
|
"genhtml ${strLCovFile} --config-file=${strBackRestBase}/test/result/coverage/raw/lcov.conf" .
|
||||||
" --prefix=${strBackRestBase}/test/.vagrant/code" .
|
" --prefix=${strTestPath}/repo" .
|
||||||
" --output-directory=${strBackRestBase}/test/result/coverage/lcov");
|
" --output-directory=${strBackRestBase}/test/result/coverage/lcov");
|
||||||
|
|
||||||
foreach my $strCodeModule (sort(keys(%{$hCoverageActual})))
|
foreach my $strCodeModule (sort(keys(%{$hCoverageActual})))
|
||||||
@ -1199,7 +1197,7 @@ eval
|
|||||||
|
|
||||||
my $strCoverageFile = $strCodeModule;
|
my $strCoverageFile = $strCodeModule;
|
||||||
$strCoverageFile =~ s/^module/test/mg;
|
$strCoverageFile =~ s/^module/test/mg;
|
||||||
$strCoverageFile = "${strBackRestBase}/test/.vagrant/code/${strCoverageFile}.lcov";
|
$strCoverageFile = "${strBackRestBase}/test/result/coverage/raw/${strCoverageFile}.lcov";
|
||||||
|
|
||||||
my $strCoverage = $oStorageBackRest->get(
|
my $strCoverage = $oStorageBackRest->get(
|
||||||
$oStorageBackRest->openRead($strCoverageFile, {bIgnoreMissing => true}));
|
$oStorageBackRest->openRead($strCoverageFile, {bIgnoreMissing => true}));
|
||||||
@ -1242,9 +1240,8 @@ eval
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$oStorageBackRest->remove("${strBackRestBase}/test/.vagrant/code/all.lcov", {bIgnoreMissing => true});
|
|
||||||
coverageGenerate(
|
coverageGenerate(
|
||||||
$oStorageBackRest, "${strBackRestBase}/test/.vagrant/code",
|
$oStorageBackRest, "${strTestPath}/repo", "${strBackRestBase}/test/result/coverage/raw",
|
||||||
"${strBackRestBase}/test/result/coverage/coverage.html");
|
"${strBackRestBase}/test/result/coverage/coverage.html");
|
||||||
|
|
||||||
if ($bCoverageSummary)
|
if ($bCoverageSummary)
|
||||||
@ -1252,7 +1249,7 @@ eval
|
|||||||
&log(INFO, 'writing C coverage summary report');
|
&log(INFO, 'writing C coverage summary report');
|
||||||
|
|
||||||
coverageDocSummaryGenerate(
|
coverageDocSummaryGenerate(
|
||||||
$oStorageBackRest, "${strBackRestBase}/test/.vagrant/code",
|
$oStorageBackRest, "${strBackRestBase}/test/result/coverage/raw",
|
||||||
"${strBackRestBase}/doc/xml/auto/metric-coverage-report.auto.xml");
|
"${strBackRestBase}/doc/xml/auto/metric-coverage-report.auto.xml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user