From 7c2adffcdec171c5c12e8275ef89e01837a6db4d Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand - Tux" Date: Fri, 1 Aug 2014 11:57:43 +0200 Subject: [PATCH] Better detect build times --- Changelog | 5 +++-- V.pm | 67 +++++++++++++++++++++++++++++----------------------------- t/20_plv56.t | 5 +++-- t/21_plv58.t | 2 +- t/23_plv512.t | 2 +- t/24_plv514.t | 2 +- t/25_plv516.t | 2 +- t/26_plv518.t | 2 +- t/26_plv5182.t | 2 +- 9 files changed, 46 insertions(+), 43 deletions(-) diff --git a/Changelog b/Changelog index c77294f..78e034c 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ -0.21 - 20 Feb 2014, H.Merijn Brand - - Add tests for each major distribution since 5.6.2 +0.21 - 01 Aug 2014, H.Merijn Brand + * Add tests for each major distribution since 5.6.2 + * Better detect build times 0.20 - 19 Feb 2014, H.Merijn Brand * Update copyright to 2014 diff --git a/V.pm b/V.pm index e5d9681..d341757 100644 --- a/V.pm +++ b/V.pm @@ -229,27 +229,26 @@ sub _make_derived sub plv2hash { my %config; - for (split m/\n+/ => join "\n", @_) { - - if (s/^Summary of my\s+(\S+)\s+\(\s*(.*?)\s*\)//) { - $config{"package"} = $1; - my $rev = $2; - $rev =~ s/^ revision \s+ (\S+) \s*//x and $config{revision} = $1; - $rev and $config{version_patchlevel_string} = $rev; - my ($rel) = $config{package} =~ m{perl(\d)}; - my ($vers, $subvers) = $rev =~ m{version\s+(\d+)\s+subversion\s+(\d+)}; - defined $vers && defined $subvers && defined $rel and - $config{version} = "$rel.$vers.$subvers"; - next; - } - if (s/^\s+(Snapshot of:)\s+(\S+)//) { - $config{git_commit_id_title} = $1; - $config{git_commit_id} = $2; - next; - } + my $pv = join "\n" => @_; + + if ($pv =~ m/^Summary of my\s+(\S+)\s+\(\s*(.*?)\s*\)/m) { + $config{"package"} = $1; + my $rev = $2; + $rev =~ s/^ revision \s+ (\S+) \s*//x and $config{revision} = $1; + $rev and $config{version_patchlevel_string} = $rev; + my ($rel) = $config{"package"} =~ m{perl(\d)}; + my ($vers, $subvers) = $rev =~ m{version\s+(\d+)\s+subversion\s+(\d+)}; + defined $vers && defined $subvers && defined $rel and + $config{version} = "$rel.$vers.$subvers"; + } + + if ($pv =~ m/^\s+(Snapshot of:)\s+(\S+)/) { + $config{git_commit_id_title} = $1; + $config{git_commit_id} = $2; + } - my %kv = m/\G,?\s*([^=]+)=('[^']+?'|\S+)/gc; + if (my %kv = ($pv =~ m/\b(\w+)\s*=\s*('[^']+?'|\S+)/g)) { while (my ($k, $v) = each %kv) { $k =~ s/\s+$//; @@ -260,8 +259,21 @@ sub plv2hash $config{$k} = $v; } } + my $build = { %empty_build }; + + $pv =~ m{^\s+Compiled at\s+(.*)}m + and $build->{stamp} = $1; + $pv =~ m{^\s+Locally applied patches:(?:\s+|\n)(.*)}m + and $build->{patches} = [ split m/\n+/, $1 ]; + $pv =~ m{^\s+Compile-time options:(?:\s+|\n)(.*)}m + and map { $build->{options}{$_} = 1 } split m/\s+|\n/ => $1; + $build->{osname} = $config{osname}; + $pv =~ m{^\s+Built under\s+(.*)}m + and $build->{osname} = $1; + $config{osname} ||= $build->{osname}; + return _make_derived ({ build => $build, environment => {}, @@ -322,20 +334,9 @@ sub myconfig } else { #y $pv = qx[$^X -e"sub Config::myconfig{};" -V]; - my $pv = qx[$^X -V]; - $pv =~ s{.*?\n\n}{}s; - $pv =~ s{\n(?: \s+|\t\s*)}{\0}g; - - # print STDERR $pv; - - $pv =~ m{^\s+Built under\s+(.*)}m - and $build->{osname} = $1; - $pv =~ m{^\s+Compiled at\s+(.*)}m - and $build->{stamp} = $1; - $pv =~ m{^\s+Locally applied patches:(?:\s+|\0)(.*)}m - and $build->{patches} = [ split m/\0+/, $1 ]; - $pv =~ m{^\s+Compile-time options:(?:\s+|\0)(.*)}m - and map { $build->{options}{$_} = 1 } split m/\s+|\0/ => $1; + my $cnf = plv2hash (qx[$^X -V]); + + $build->{$_} = $cnf->{build}{$_} for qw( osname stamp patches options ); } my @KEYS = keys %ENV; diff --git a/t/20_plv56.t b/t/20_plv56.t index d9e1c24..f4cc998 100644 --- a/t/20_plv56.t +++ b/t/20_plv56.t @@ -5,7 +5,7 @@ use warnings; BEGIN { use Test::More; - my $tests = 8; + my $tests = 9; unless ($ENV{PERL_CORE}) { require Test::NoWarnings; Test::NoWarnings->import (); @@ -21,7 +21,8 @@ ok (my $conf = Config::Perl::V::plv2hash (), "Read perl -v block"); ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc ); is ($conf->{build}{osname}, $conf->{config}{osname}, "osname"); -is ($conf->{build}{stamp}, 0, "No build time known"); +is ($conf->{build}{stamp}, "Mar 23 2010 17:34:56", "Build time"); +is ($conf->{config}{"package"}, "perl5", "reconstructed \%Config{package}"); is ($conf->{config}{version}, "5.6.2", "reconstructed \%Config{version}"); __END__ diff --git a/t/21_plv58.t b/t/21_plv58.t index 4fec357..1e6ce62 100644 --- a/t/21_plv58.t +++ b/t/21_plv58.t @@ -21,7 +21,7 @@ ok (my $conf = Config::Perl::V::plv2hash (), "Read perl -v block"); ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc ); is ($conf->{build}{osname}, $conf->{config}{osname}, "osname"); -is ($conf->{build}{stamp}, 0, "No build time known"); +is ($conf->{build}{stamp}, "Oct 21 2010 14:50:53", "Build time"); is ($conf->{config}{version}, "5.8.9", "reconstructed \%Config{version}"); is ($conf->{config}{usethreads}, "define", "This was a threaded perl"); diff --git a/t/23_plv512.t b/t/23_plv512.t index ee36b26..9f4b146 100644 --- a/t/23_plv512.t +++ b/t/23_plv512.t @@ -21,7 +21,7 @@ ok (my $conf = Config::Perl::V::plv2hash (), "Read perl -v block"); ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc ); is ($conf->{build}{osname}, $conf->{config}{osname}, "osname"); -is ($conf->{build}{stamp}, 0, "No build time known"); +is ($conf->{build}{stamp}, "Dec 20 2010 12:46:00", "Build time"); is ($conf->{config}{version}, "5.12.2", "reconstructed \%Config{version}"); is ($conf->{config}{gccversion}, "", "not built with gcc"); is ($conf->{config}{ccversion}, "B3910B", "built with HP C-ANSI-C"); diff --git a/t/24_plv514.t b/t/24_plv514.t index b1b4ff9..81a8016 100644 --- a/t/24_plv514.t +++ b/t/24_plv514.t @@ -21,7 +21,7 @@ ok (my $conf = Config::Perl::V::plv2hash (), "Read perl -v block"); ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc ); is ($conf->{build}{osname}, $conf->{config}{osname}, "osname"); -is ($conf->{build}{stamp}, 0, "no build time known"); +is ($conf->{build}{stamp}, "May 11 2012 16:36:53", "Build time"); is ($conf->{config}{version}, "5.14.2", "reconstructed \%Config{version}"); is ($conf->{config}{gccversion}, "", "not built with gcc"); is ($conf->{config}{ccversion}, "11.1.0.8", "xlc version"); diff --git a/t/25_plv516.t b/t/25_plv516.t index 9e5613e..734940a 100644 --- a/t/25_plv516.t +++ b/t/25_plv516.t @@ -21,7 +21,7 @@ ok (my $conf = Config::Perl::V::plv2hash (), "Read perl -v block"); ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc ); is ($conf->{build}{osname}, $conf->{config}{osname}, "osname"); -is ($conf->{build}{stamp}, 0, "no build time known"); +is ($conf->{build}{stamp}, "Mar 12 2013 08:36:17", "Build time"); is ($conf->{config}{version}, "5.16.3", "reconstructed \%Config{version}"); is ($conf->{config}{ccversion}, "", "Using gcc. nonn-gcc version should not be defined"); diff --git a/t/26_plv518.t b/t/26_plv518.t index ed0a2a6..330fe34 100644 --- a/t/26_plv518.t +++ b/t/26_plv518.t @@ -21,7 +21,7 @@ ok (my $conf = Config::Perl::V::plv2hash (), "Read perl -v block"); ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc ); is ($conf->{build}{osname}, $conf->{config}{osname}, "osname"); -is ($conf->{build}{stamp}, 0, "No build time known"); +is ($conf->{build}{stamp}, "May 18 2013 17:34:20", "Build time"); is ($conf->{config}{version}, "5.18.0", "reconstructed \$Config{version}"); # Some random checks diff --git a/t/26_plv5182.t b/t/26_plv5182.t index d5dde71..beae297 100644 --- a/t/26_plv5182.t +++ b/t/26_plv5182.t @@ -21,7 +21,7 @@ ok (my $conf = Config::Perl::V::plv2hash (), "Read perl -v block"); ok (exists $conf->{$_}, "Has $_ entry") for qw( build environment config inc ); is ($conf->{build}{osname}, $conf->{config}{osname}, "osname"); -is ($conf->{build}{stamp}, 0, "No build time known"); +is ($conf->{build}{stamp}, "Jan 9 2014 09:22:04", "Build time"); is ($conf->{config}{version}, "5.18.2", "reconstructed \$Config{version}"); # Some random checks -- 2.11.4.GIT