From 3879ea51d63e30f393172fcd711bc89f88997019 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 28 Sep 2010 16:50:26 +0100 Subject: [PATCH] A test to check that regen.pl doesn't need running. We can't run regen.pl as part of the build, as we'd end up with a circular dependency between the headers and miniperl. --- MANIFEST | 1 + regen.pl | 3 ++- regen_lib.pl | 9 ++++++++- t/porting/regen.t | 23 +++++++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 t/porting/regen.t diff --git a/MANIFEST b/MANIFEST index 3cf53aa..c551152 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4689,6 +4689,7 @@ t/porting/exec-bit.t Check that exec-bit bins are identified t/porting/maintainers.t Test that Porting/Maintaners.pl is up to date t/porting/manifest.t Test that this MANIFEST file is well formed t/porting/podcheck.t Test the POD of shipped modules is well formed +t/porting/regen.t Check that regen.pl doesn't need running t/porting/test_bootstrap.t Test that the instructions for test bootstrapping aren't accidentally overlooked. t/README Instructions for regression tests t/re/overload.t Test against string corruption in pattern matches on overloaded objects diff --git a/regen.pl b/regen.pl index f97a618..f103b0a 100644 --- a/regen.pl +++ b/regen.pl @@ -26,8 +26,9 @@ warnings.pl embed.pl ); +my $tap = $ARGV[0] && $ARGV[0] eq '--tap' ? '# ' : ''; foreach my $pl (@scripts) { my @command = ($^X, $pl, @ARGV); - print "@command\n"; + print "$tap@command\n"; system @command; } diff --git a/regen_lib.pl b/regen_lib.pl index 7d396c0..9008629 100644 --- a/regen_lib.pl +++ b/regen_lib.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w use strict; -use vars qw($Needs_Write $Verbose @Changed); +use vars qw($Needs_Write $Verbose @Changed $TAP); use File::Compare; use Symbol; @@ -10,6 +10,7 @@ $Needs_Write = $^O eq 'cygwin' || $^O eq 'os2' || $^O eq 'MSWin32'; $Verbose = 0; @ARGV = grep { not($_ eq '-q' and $Verbose = -1) } + grep { not($_ eq '--tap' and $TAP = 1) } grep { not($_ eq '-v' and $Verbose = 1) } @ARGV; END { @@ -42,6 +43,12 @@ sub safer_rename_silent { sub rename_if_different { my ($from, $to) = @_; + if ($TAP) { + my $not = compare($from, $to) ? 'not ' : ''; + print STDOUT $not . "ok - $0 $to\n"; + safer_unlink($from); + return; + } if (compare($from, $to) == 0) { warn "no changes between '$from' & '$to'\n" if $Verbose > 0; safer_unlink($from); diff --git a/t/porting/regen.t b/t/porting/regen.t new file mode 100644 index 0000000..9699d55 --- /dev/null +++ b/t/porting/regen.t @@ -0,0 +1,23 @@ +#!./perl -w + +# Verify that all files generated by perl scripts are up to date. + +my ($in_t, $lib); + +BEGIN { + $in_t = -f 'TEST' && -f '../regen.pl'; + $lib = $in_t ? '../lib' : 'lib'; + unshift @INC, $lib; +} + +use strict; + +use File::Spec::Functions 'rel2abs'; +$^X = rel2abs($^X); +$ENV{PERL5LIB} = rel2abs($lib); + +chdir '..' if $in_t; + +print "1..17\n"; # I can't see a clean way to calculate this automatically. + +system "$^X regen.pl --tap"; -- 1.8.3.1