Skip to content

Commit

Permalink
Skip version checks when testing in --dev mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsteele committed Apr 9, 2018
1 parent 3bcf637 commit c9ce20d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 40 deletions.
2 changes: 1 addition & 1 deletion doc/xml/release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</release-item>

<release-item>
<p>Improve logic for smart builds to include version changes.</p>
<p>Improve logic for smart builds to include version changes. Skip version checks when testing in <setting>--dev</setting> mode.</p>
</release-item>

<release-item>
Expand Down
88 changes: 49 additions & 39 deletions test/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
use pgBackRestBuild::Error::Build;
use pgBackRestBuild::Error::Data;

use BackRestDoc::Custom::DocCustomRelease;

use pgBackRestTest::Common::BuildTest;
use pgBackRestTest::Common::ContainerTest;
use pgBackRestTest::Common::CiTest;
Expand Down Expand Up @@ -401,53 +399,65 @@ =head1 SYNOPSIS
(new pgBackRestTest::Common::CiTest($oStorageBackRest))->process();
}

&log(INFO, "check version info");

# Load the doc module dynamically since it is not supported on all systems
require BackRestDoc::Common::Doc;
BackRestDoc::Common::Doc->import();

# Make sure version number matches the latest release
my $strReleaseFile = dirname(dirname(abs_path($0))) . '/doc/xml/release.xml';
my $oRelease = (new BackRestDoc::Custom::DocCustomRelease(new BackRestDoc::Common::Doc($strReleaseFile)))->releaseLast();
my $strVersion = $oRelease->paramGet('version');
my $bVersionDev = false;
my $strVersionBase = $strVersion;
# Check Perl version against release notes and update version in C code if needed
#---------------------------------------------------------------------------------------------------------------------------
my $bVersionDev = true;
my $strVersionBase;

if ($strVersion =~ /dev$/)
if (!$bDev)
{
$bVersionDev = true;
$strVersionBase = substr($strVersion, 0, length($strVersion) - 3);
# Make sure version number matches the latest release
#-----------------------------------------------------------------------------------------------------------------------
&log(INFO, "check version info");

# Load the doc modules dynamically since they are not supported on all systems
require BackRestDoc::Common::Doc;
BackRestDoc::Common::Doc->import();
require BackRestDoc::Custom::DocCustomRelease;
BackRestDoc::Custom::DocCustomRelease->import();

my $strReleaseFile = dirname(dirname(abs_path($0))) . '/doc/xml/release.xml';
my $oRelease =
(new BackRestDoc::Custom::DocCustomRelease(new BackRestDoc::Common::Doc($strReleaseFile)))->releaseLast();
my $strVersion = $oRelease->paramGet('version');
$bVersionDev = false;
$strVersionBase = $strVersion;

if ($strVersion =~ /dev$/)
{
$bVersionDev = true;
$strVersionBase = substr($strVersion, 0, length($strVersion) - 3);

if (BACKREST_VERSION !~ /dev$/ && $oRelease->nodeTest('release-core-list'))
if (BACKREST_VERSION !~ /dev$/ && $oRelease->nodeTest('release-core-list'))
{
confess "dev release ${strVersion} must match the program version when core changes have been made";
}
}
elsif ($strVersion ne BACKREST_VERSION)
{
confess "dev release ${strVersion} must match the program version when core changes have been made";
confess 'unable to find version ' . BACKREST_VERSION . " as the most recent release in ${strReleaseFile}";
}
}
elsif ($strVersion ne BACKREST_VERSION)
{
confess 'unable to find version ' . BACKREST_VERSION . " as the most recent release in ${strReleaseFile}";
}

# Update version for the C code based on the current Perl version
#---------------------------------------------------------------------------------------------------------------------------
my $strCVersionFile = "${strBackRestBase}/src/version.h";
my $strCVersionOld = ${$oStorageTest->get($strCVersionFile)};
my $strCVersionNew;
# Update version for the C code based on the current Perl version
#-----------------------------------------------------------------------------------------------------------------------
my $strCVersionFile = "${strBackRestBase}/src/version.h";
my $strCVersionOld = ${$oStorageTest->get($strCVersionFile)};
my $strCVersionNew;

foreach my $strLine (split("\n", $strCVersionOld))
{
if ($strLine =~ /^#define PGBACKREST_VERSION/)
foreach my $strLine (split("\n", $strCVersionOld))
{
$strLine = '#define PGBACKREST_VERSION' . (' ' x 42) . '"' . BACKREST_VERSION . '"';
}
if ($strLine =~ /^#define PGBACKREST_VERSION/)
{
$strLine = '#define PGBACKREST_VERSION' . (' ' x 42) . '"' . BACKREST_VERSION . '"';
}

$strCVersionNew .= "${strLine}\n";
}
$strCVersionNew .= "${strLine}\n";
}

if ($strCVersionNew ne $strCVersionOld)
{
$oStorageTest->put($strCVersionFile, $strCVersionNew);
if ($strCVersionNew ne $strCVersionOld)
{
$oStorageTest->put($strCVersionFile, $strCVersionNew);
}
}

# Clean up
Expand Down

0 comments on commit c9ce20d

Please sign in to comment.