In perl.git, the branch smoke-me/nicholas/regen has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/d2252d8f0bf2fd28d344e1ffb25b48d19dee46ff?hp=342e471005ed70e116b7424940356bf271a058c9>

- Log -----------------------------------------------------------------
commit d2252d8f0bf2fd28d344e1ffb25b48d19dee46ff
Author: Nicholas Clark <[email protected]>
Date:   Thu Jul 18 16:57:00 2013 +0200

    Refactor t/porting/regen.t to check everything (and the return values!).
    
    Previously it was fire-and-forget for the 3 programs it ran (and for the
    programs that regen.pl ran). Now we die if any program fails to return 0.
    
    Also regen.t had an explicit list of programs to test. It turned out that it
    was not testing regen/mk_invlists.pl. Now regen.t has a skip list of what
    not to test, and everything not skipped it tested. This way any new
    additions will not get missed.
    
    This was implemented by refactoring regen.pl to read the list of programs it
    runs from <DATA>, so that regen.t can open regen.pl to extract the same
    list.

M       regen.pl
M       t/porting/regen.t

commit a78f953fb604e1f9bd1092efbcfe5c338f60c735
Author: Nicholas Clark <[email protected]>
Date:   Thu Jul 18 15:10:29 2013 +0200

    Syntax check regen/uconfig_h.pl using t/porting/utils.t
    
    It's the only regen script that we can't run as part of the tests (because 
it
    requires a Unix shell), but can syntax check (because it only uses core
    modules).
    
    In theory we could make it skip with --tap if $Config{sh} is not what we
    expect, but to be robust this looks to be a problem. Firstly, $Config{sh}
    can be undef, or something "non-Unix". To be useful a whitelist needs to be
    (at least) (?:/usr)?/bin/sh, and potentially also ksh. But the output is not
    valid TAP:
    
    $ ./perl -Ilib regen/uconfig_h.pl --tap
    Extracting uconfig.h-new (with variable substitutions)
    ok - regen/uconfig_h.pl uconfig.h
    
    and t/TEST would choke, so we'd need to capture it or otherwise comment out
    that "Extracting" line which just adds both complexity and fragility.
    
    So the right trade off appears to be just to syntax check it.

M       t/porting/utils.t
-----------------------------------------------------------------------

Summary of changes:
 regen.pl          | 18 ++++++++----------
 t/porting/regen.t | 46 ++++++++++++++++++++++++++++++++++------------
 t/porting/utils.t |  7 ++++++-
 3 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/regen.pl b/regen.pl
index 1b3ae5e..8788668 100644
--- a/regen.pl
+++ b/regen.pl
@@ -13,9 +13,15 @@ require 5.004;       # keep this compatible, an old perl is 
all we may have before
 
 use strict;
 
-# Which scripts to run.
+my $tap = $ARGV[0] && $ARGV[0] eq '--tap' ? '# ' : '';
+foreach my $pl (map {chomp; "regen/$_"} <DATA>) {
+  my @command =  ($^X, $pl, @ARGV);
+  print "$tap@command\n";
+  system @command
+    and die "@command failed: $?" 
+}
 
-my @scripts = qw(
+__END__
 mg_vtable.pl
 opcode.pl
 overload.pl
@@ -24,11 +30,3 @@ regcomp.pl
 warnings.pl
 embed.pl
 feature.pl
-);
-
-my $tap = $ARGV[0] && $ARGV[0] eq '--tap' ? '# ' : '';
-foreach my $pl (map {"regen/$_"} @scripts) {
-  my @command =  ($^X, $pl, @ARGV);
-  print "$tap@command\n";
-  system @command;
-}
diff --git a/t/porting/regen.t b/t/porting/regen.t
index 78fd64f..f7ec411 100644
--- a/t/porting/regen.t
+++ b/t/porting/regen.t
@@ -16,13 +16,37 @@ if ( $^O eq "VMS" ) {
   skip_all( "- regen.pl needs porting." );
 }
 
-my $in_regen_pl = 24; # I can't see a clean way to calculate this 
automatically.
-my @files = qw(perly.act perly.h perly.tab keywords.c keywords.h uconfig.h);
-my @progs = qw(regen/regcharclass.pl regen/mk_PL_charclass.pl
-               regen/unicode_constants.pl regen/genpacksizetables.pl
-               regen/miniperlmain.pl);
+my $tests = 23; # I can't see a clean way to calculate this automatically.
 
-plan (tests => $in_regen_pl + @files + @progs + 2);
+my %skip = ("regen_perly.pl"    => [qw(perly.act perly.h perly.tab)],
+            "regen/keywords.pl" => [qw(keywords.c keywords.h)],
+            "regen/uconfig_h.h" => [qw(uconfig.h)],
+           );
+
+my @files = map {@$_} sort values %skip;
+
+open my $fh, '<', 'regen.pl'
+    or die "Can't open regen.pl: $!";
+
+while (<$fh>) {
+    last if /^__END__/;
+}
+die "Can't find __END__ in regen.pl"
+    if eof $fh;
+
+foreach (qw(embed_lib.pl regen_lib.pl uconfig_h.pl
+            regcharclass_multi_char_folds.pl),
+         map {chomp $_; $_} <$fh>) {
+    ++$skip{"regen/$_"};
+}
+
+close $fh
+    or die "Can't close regen.pl: $!";
+
+my @progs = grep {!$skip{$_}} <regen/*.pl>;
+push @progs, 'regen.pl', map {"Porting/makemeta $_"} qw(-j -y);
+
+plan (tests => $tests + @files + @progs);
 
 OUTER: foreach my $file (@files) {
     open my $fh, '<', $file or die "Can't open $file: $!";
@@ -46,10 +70,8 @@ OUTER: foreach my $file (@files) {
     is("@bad", '', "generated $file is up to date");
 }
 
-foreach (@progs, 'regen.pl') {
-  system "$^X $_ --tap";
-}
-
-foreach ( '-y', '-j' ) {
-  system "$^X Porting/makemeta --tap $_";
+foreach (@progs) {
+    my $command = "$^X $_ --tap";
+    system $command
+        and die "Failed to run $command: $?";
 }
diff --git a/t/porting/utils.t b/t/porting/utils.t
index ba8ba23..25fb802 100644
--- a/t/porting/utils.t
+++ b/t/porting/utils.t
@@ -47,7 +47,12 @@ while (<$fh>) {
 }
 close $fh or die $!;
 
-my @victims = (qw(installman installperl regen_perly.pl));
+# regen/uconfig_h.pl is here because it's not possible to test it by running
+# it on non-*nix platforms, as it requires a Bourne shell. As it's the only 
file
+# in regen/ which we can syntax check but can't run, it's simpler to add it to
+# the list here, than copy-paste the entire syntax-checking logic to
+# t/porting/regen.t
+my @victims = (qw(installman installperl regen_perly.pl regen/uconfig_h.pl));
 my %excuses = (
                'Porting/git-deltatool' => 'Git::Wrapper',
                'Porting/podtidy' => 'Pod::Tidy',

--
Perl5 Master Repository

Reply via email to