# 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;
+ @INC = '..' if -f '../TestInit.pm';
}
-
+use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
use strict;
-use File::Spec::Functions 'rel2abs';
-$^X = rel2abs($^X);
-$ENV{PERL5LIB} = rel2abs($lib);
-
-chdir '..' if $in_t;
-
-$INC[0] = 'lib';
-require 'regen/regen_lib.pl';
-require 't/test.pl';
+require './regen/regen_lib.pl';
+require './t/test.pl';
$::NO_ENDING = $::NO_ENDING = 1;
if ( $^O eq "VMS" ) {
skip_all( "- regen.pl needs porting." );
}
+if ($^O eq 'dec_osf') {
+ skip_all("$^O cannot handle this test");
+}
+if ( $::IS_EBCDIC || $::IS_EBCDIC) {
+ skip_all( "- We don't regen on EBCDIC." );
+}
+use Config;
+if ( $Config{usecrosscompile} ) {
+ skip_all( "Not all files are available during cross-compilation" );
+}
+
+my $tests = 27; # I can't see a clean way to calculate this automatically.
+
+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)],
+ "regen/mk_invlists.pl" => [qw(charclass_invlists.h uni_keywords.h)],
+ "regen/regcharclass.pl" => [qw(regcharclass.h)],
+ );
-my $in_regen_pl = 19; # 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(Porting/makemeta regen/regcharclass.pl regen/mk_PL_charclass.pl);
+my %other_requirement = (
+ "regen_perly.pl" => "requires bison",
+ "regen/keywords.pl" => "requires Devel::Tokenizer::C",
+ "regen/mk_invlists.pl" => "needs the Perl you've just built",
+ "regen/regcharclass.pl" => "needs the Perl you've just built",
+);
+
+my %skippable_script_for_target;
+for my $script (keys %other_requirement) {
+ $skippable_script_for_target{$_} = $script
+ for @{ $skip{$script} };
+}
-plan (tests => $in_regen_pl + @files + @progs);
+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
+ charset_translations.pl
+ mph.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: $!";
fail("Bad line in $file: '$_'");
next OUTER;
}
+
my $digest = digest($2);
note("$digest $2");
push @bad, $2 unless $digest eq $1;
}
is("@bad", '', "generated $file is up to date");
+ if (@bad && (my $skippable_script = $skippable_script_for_target{$file})) {
+ my $reason = delete $other_requirement{$skippable_script};
+ diag("Note: $skippable_script must be run manually, because it $reason")
+ if $reason;
+ }
}
-foreach (@progs, 'regen.pl') {
- system "$^X $_ --tap";
+foreach (@progs) {
+ my $command = "$^X -I. $_ --tap";
+ system $command
+ and die "Failed to run $command: $?";
}