Skip to content

Commit

Permalink
Item14431: Improve dependency check for DBD, DBI::Pg
Browse files Browse the repository at this point in the history
Unexpected version strings break the extract.
  • Loading branch information
gac410 committed Jul 11, 2017
1 parent d1be075 commit 90fac34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions UnitTestContrib/test/unit/DependencyTests.pm
Expand Up @@ -346,6 +346,23 @@ sub test_check_dep_version_with_underscore {

}

sub test_check_dep_version_oddball_DBI {
my ($this) = @_;

# Check a normal installed dependency with a version number that includes _
# 1, Algorithm::Diff v1.19_01 installed
my $dep = new Foswiki::Configure::Dependency(
type => "perl",
module => "DBI",
version => ">=1"
);
my ( $ok, $message ) = $dep->checkDependency();
$this->assert_equals( 1, $ok );
$this->assert_matches( qr/DBI version \d+\.\d+(?:_\d+)? installed/,
$message );

}

sub test_compare_extension_versions {
my ($this) = @_;

Expand Down
7 changes: 5 additions & 2 deletions core/lib/Foswiki/Configure/Dependency.pm
Expand Up @@ -814,7 +814,7 @@ sub extractModuleVersion {
$mod_version = $1;
}
if (
/^\s*(?:our\s+)?\$(?:\w*::)*(RELEASE|VERSION)\s*=(?!~)\s*(.*);/
/\s*(?:our\s+)?\$(?:\w*::)*(RELEASE|VERSION)\s*=(?!~)\s*(.*);/
)
{
eval( "\$mod_" . lc($1) . " = $2;" );
Expand All @@ -825,7 +825,10 @@ sub extractModuleVersion {
}
next;
}
next unless (/^\s*(?:our\s+)?\$(?:\w*::)*VERSION\s*=\s*(.*?);/);
next
unless (
/\s*(?:our\s+)?\$(?:\w*::)*VERSION\s*=\s*(?:qv\()?(.*?)(?:\))?;/
);
eval("\$mod_version = $1;");

# die "Failed to eval $1 from $_ in $file at line $. $@\n" if( $@ ); # DEBUG
Expand Down

0 comments on commit 90fac34

Please sign in to comment.