From: Vincent Pit Date: Fri, 29 Jul 2016 17:05:11 +0000 (-0300) Subject: More lax valgrind version parsing X-Git-Tag: v1.19~4 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=f69f14a04c9b6c47bb1468e192977632cc1c854a;p=perl%2Fmodules%2FTest-Valgrind.git More lax valgrind version parsing If valgrind ever decides to add a full stop at the end of the output of "valgrind --version", then the (?!\.) in the version parsing regexp will cause unexpected backtracking which will result in an invalid version. --- diff --git a/lib/Test/Valgrind/Version.pm b/lib/Test/Valgrind/Version.pm index b2da36b..94661bb 100644 --- a/lib/Test/Valgrind/Version.pm +++ b/lib/Test/Valgrind/Version.pm @@ -65,11 +65,11 @@ sub new { my $output = $args{command_output}; my $string; if (defined $output) { - ($string) = $output =~ /^valgrind-([0-9]+(?:\.[0-9]+)*)(?!\.)/; + ($string) = $output =~ /^valgrind-([0-9]+(?:\.[0-9]+)*)/; } else { $string = $args{string}; return $string if $string->$instanceof(__PACKAGE__); - if (defined $string and $string =~ /^([0-9]+(?:\.[0-9]+)*)(?!\.)/) { + if (defined $string and $string =~ /^([0-9]+(?:\.[0-9]+)*)/) { $string = $1; } else { $string = undef; diff --git a/t/60-version.t b/t/60-version.t index 4b6b2a9..68a99a0 100644 --- a/t/60-version.t +++ b/t/60-version.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 6 + 6 + 2 * 5 + 2 * 5 + 2 * 21 + 2 * 14; +use Test::More tests => 6 + 5 + 4 * 8 + 2 * 21 + 2 * 14; use Test::Valgrind::Version; @@ -40,9 +40,8 @@ my @string_failures = ( undef, 'valgrind', 'valgrind-1.2.3', - '1.', - '1.2.', - '1.2.a', + 'abc', + 'd.e.f', ); for my $failure (@string_failures) { @@ -59,6 +58,9 @@ my @command_valid = ( 'valgrind-1.2.3' => '1.2.3', 'valgrind-1.2.4-rc5' => '1.2.4', 'valgrind-1.2.6a' => '1.2.6', + 'valgrind-1.2.7.' => '1.2.7', + 'valgrind-1.2.x.8' => '1.2.0', + 'valgrind-1.10.' => '1.10.0', ); my @string_valid = map { my $s = $_; $s =~ s/^valgrind-//; $s }