mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +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:
parent
d702249507
commit
4328bc1ac6
@ -71,6 +71,7 @@ push @EXPORT, qw(coverageLCovConfigGenerate);
|
||||
sub coverageGenerate
|
||||
{
|
||||
my $oStorage = shift;
|
||||
my $strBasePath = shift;
|
||||
my $strCoveragePath = shift;
|
||||
my $strOutFile = shift;
|
||||
|
||||
@ -87,8 +88,7 @@ sub coverageGenerate
|
||||
my $strCoverage = ${$oStorage->get("${strCoveragePath}/${strFileCov}")};
|
||||
|
||||
# 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';
|
||||
$rhCoverage->{$strFile} = undef;
|
||||
my $strFile;
|
||||
|
||||
my $iBranchLine = -1;
|
||||
my $iBranch = undef;
|
||||
@ -97,8 +97,14 @@ sub coverageGenerate
|
||||
|
||||
foreach my $strLine (split("\n", $strCoverage))
|
||||
{
|
||||
# Get source file name
|
||||
if ($strLine =~ /^SF\:/)
|
||||
{
|
||||
$strFile = substr($strLine, 3);
|
||||
$rhCoverage->{$strFile} = undef;
|
||||
}
|
||||
# Check branch coverage
|
||||
if ($strLine =~ /^BRDA\:/)
|
||||
elsif ($strLine =~ /^BRDA\:/)
|
||||
{
|
||||
my @stryData = split("\,", substr($strLine, 5));
|
||||
|
||||
@ -216,7 +222,7 @@ sub coverageGenerate
|
||||
{
|
||||
if (defined($rhCoverage->{$strFile}{line}))
|
||||
{
|
||||
my $strC = ${$oStorage->get("${strCoveragePath}/${strFile}")};
|
||||
my $strC = ${$oStorage->get($strFile)};
|
||||
my @stryC = split("\n", $strC);
|
||||
|
||||
foreach my $iLine (sort(keys(%{$rhCoverage->{$strFile}{line}})))
|
||||
@ -435,7 +441,7 @@ sub coverageGenerate
|
||||
foreach my $strFile (sort(keys(%{$rhCoverage})))
|
||||
{
|
||||
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
|
||||
@ -446,14 +452,14 @@ sub coverageGenerate
|
||||
# Build the file 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->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-code', {strContent => 'CODE'});
|
||||
|
||||
my $strC = ${$oStorage->get("${strCoveragePath}/${strFile}")};
|
||||
my $strC = ${$oStorage->get($strFile)};
|
||||
my @stryC = split("\n", $strC);
|
||||
my $iLastLine = undef;
|
||||
|
||||
|
@ -626,7 +626,7 @@ sub end
|
||||
"module/$self->{oTest}->{&TEST_MODULE}/" . testRunName($self->{oTest}->{&TEST_NAME}, false) . 'Test');
|
||||
|
||||
# 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});
|
||||
|
||||
my $strLCovExeBase = "lcov --config-file=${strLCovConf}";
|
||||
@ -659,9 +659,12 @@ sub end
|
||||
}
|
||||
|
||||
# Generate lcov reports
|
||||
my $strModulePath = $self->{strBackRestBase} . "/test/.vagrant/code/${strModuleOutName}";
|
||||
my $strLCovFile = "${strModulePath}.lcov";
|
||||
my $strLCovTotal = $self->{strBackRestBase} . "/test/.vagrant/code/all.lcov";
|
||||
my $strModulePath =
|
||||
$self->{strTestPath} . "/repo/" .
|
||||
(${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(
|
||||
"${strLCovExe} --extract=${strLCovOut} */${strModuleName}.c --o=${strLCovOutTmp}");
|
||||
@ -709,7 +712,8 @@ sub end
|
||||
# Fix source file name
|
||||
$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))
|
||||
{
|
||||
|
29
test/test.pl
29
test/test.pl
@ -623,7 +623,7 @@ eval
|
||||
my $iTestFail = 0;
|
||||
my $iTestRetry = 0;
|
||||
my $oyProcess = [];
|
||||
my $strCodePath = "${strBackRestBase}/test/.vagrant/code";
|
||||
my $strCodePath = "${strBackRestBase}/test/result/coverage/raw";
|
||||
|
||||
if (!$bDryRun || $bVmOut)
|
||||
{
|
||||
@ -639,10 +639,11 @@ eval
|
||||
push(@{$oyProcess}, undef);
|
||||
}
|
||||
|
||||
executeTest("rm -rf ${strTestPath}/test-* ${strTestPath}/data-*" . ($bDev ? '' : " ${strTestPath}/gcov-*"));
|
||||
$oStorageTest->pathCreate($strTestPath, {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
||||
executeTest(
|
||||
"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/*");
|
||||
|
||||
# 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
|
||||
if (vmCoverageC($strVm) && !$bDryRun)
|
||||
{
|
||||
$oStorageTest->pathCreate("${strCodePath}/test", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
||||
|
||||
executeTest(
|
||||
"rsync -rt --delete --exclude=test ${strBackRestBase}/src/ ${strCodePath} && " .
|
||||
"rsync -rt --delete ${strBackRestBase}/test/src/module/ ${strCodePath}/test");
|
||||
executeTest("rm -rf ${strBackRestBase}/test/result/coverage/raw/*");
|
||||
$oStorageTest->pathCreate("${strCodePath}", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1180,13 +1178,13 @@ eval
|
||||
{
|
||||
&log(INFO, 'writing C coverage report');
|
||||
|
||||
my $strLCovFile = "${strBackRestBase}/test/.vagrant/code/all.lcov";
|
||||
my $strLCovFile = "${strTestPath}/temp/all.lcov";
|
||||
|
||||
if ($oStorageBackRest->exists($strLCovFile))
|
||||
{
|
||||
executeTest(
|
||||
"genhtml ${strLCovFile} --config-file=${strBackRestBase}/test/.vagrant/code/lcov.conf" .
|
||||
" --prefix=${strBackRestBase}/test/.vagrant/code" .
|
||||
"genhtml ${strLCovFile} --config-file=${strBackRestBase}/test/result/coverage/raw/lcov.conf" .
|
||||
" --prefix=${strTestPath}/repo" .
|
||||
" --output-directory=${strBackRestBase}/test/result/coverage/lcov");
|
||||
|
||||
foreach my $strCodeModule (sort(keys(%{$hCoverageActual})))
|
||||
@ -1199,7 +1197,7 @@ eval
|
||||
|
||||
my $strCoverageFile = $strCodeModule;
|
||||
$strCoverageFile =~ s/^module/test/mg;
|
||||
$strCoverageFile = "${strBackRestBase}/test/.vagrant/code/${strCoverageFile}.lcov";
|
||||
$strCoverageFile = "${strBackRestBase}/test/result/coverage/raw/${strCoverageFile}.lcov";
|
||||
|
||||
my $strCoverage = $oStorageBackRest->get(
|
||||
$oStorageBackRest->openRead($strCoverageFile, {bIgnoreMissing => true}));
|
||||
@ -1242,9 +1240,8 @@ eval
|
||||
}
|
||||
}
|
||||
|
||||
$oStorageBackRest->remove("${strBackRestBase}/test/.vagrant/code/all.lcov", {bIgnoreMissing => true});
|
||||
coverageGenerate(
|
||||
$oStorageBackRest, "${strBackRestBase}/test/.vagrant/code",
|
||||
$oStorageBackRest, "${strTestPath}/repo", "${strBackRestBase}/test/result/coverage/raw",
|
||||
"${strBackRestBase}/test/result/coverage/coverage.html");
|
||||
|
||||
if ($bCoverageSummary)
|
||||
@ -1252,7 +1249,7 @@ eval
|
||||
&log(INFO, 'writing C coverage summary report');
|
||||
|
||||
coverageDocSummaryGenerate(
|
||||
$oStorageBackRest, "${strBackRestBase}/test/.vagrant/code",
|
||||
$oStorageBackRest, "${strBackRestBase}/test/result/coverage/raw",
|
||||
"${strBackRestBase}/doc/xml/auto/metric-coverage-report.auto.xml");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user