3 # Verify that all files generated by perl scripts are up to date.
6 @INC = '..' if -f '../TestInit.pm';
8 use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
11 require 'regen/regen_lib.pl';
13 $::NO_ENDING = $::NO_ENDING = 1;
16 skip_all( "- regen.pl needs porting." );
18 if ($^O eq 'dec_osf') {
19 skip_all("$^O cannot handle this test");
22 if ( $Config{usecrosscompile} ) {
23 skip_all( "Not all files are available during cross-compilation" );
26 my $tests = 26; # I can't see a clean way to calculate this automatically.
28 my %skip = ("regen_perly.pl" => [qw(perly.act perly.h perly.tab)],
29 "regen/keywords.pl" => [qw(keywords.c keywords.h)],
30 "regen/uconfig_h.h" => [qw(uconfig.h)],
33 my @files = map {@$_} sort values %skip;
35 open my $fh, '<', 'regen.pl'
36 or die "Can't open regen.pl: $!";
41 die "Can't find __END__ in regen.pl"
44 foreach (qw(embed_lib.pl regen_lib.pl uconfig_h.pl
45 regcharclass_multi_char_folds.pl
46 charset_translations.pl
48 map {chomp $_; $_} <$fh>) {
53 or die "Can't close regen.pl: $!";
55 my @progs = grep {!$skip{$_}} <regen/*.pl>;
56 push @progs, 'regen.pl', map {"Porting/makemeta $_"} qw(-j -y);
58 plan (tests => $tests + @files + @progs);
60 OUTER: foreach my $file (@files) {
61 open my $fh, '<', $file or die "Can't open $file: $!";
62 1 while defined($_ = <$fh>) and !/Generated from:/;
64 fail("Can't find 'Generated from' line in $file");
69 last if /ex: set ro:/;
70 unless (/^(?: \* | #)([0-9a-f]+) (\S+)$/) {
72 fail("Bad line in $file: '$_'");
75 my $digest = digest($2);
77 push @bad, $2 unless $digest eq $1;
79 is("@bad", '', "generated $file is up to date");
83 my $command = "$^X $_ --tap";
85 and die "Failed to run $command: $?";