This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
e127eb0d46048db03d51d9cc3c0168a96305320a
[perl5.git] / t / porting / regen.t
1 #!./perl -w
2
3 # Verify that all files generated by perl scripts are up to date.
4
5 BEGIN {
6     @INC = '..' if -f '../TestInit.pm';
7 }
8 use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
9 use strict;
10
11 require 'regen/regen_lib.pl';
12 require 't/test.pl';
13 $::NO_ENDING = $::NO_ENDING = 1;
14
15 if ( $^O eq "VMS" ) {
16   skip_all( "- regen.pl needs porting." );
17 }
18
19 my $in_regen_pl = 23; # I can't see a clean way to calculate this automatically.
20 my @files = qw(perly.act perly.h perly.tab keywords.c keywords.h uconfig.h);
21 my @progs = qw(regen/regcharclass.pl regen/mk_PL_charclass.pl);
22
23 plan (tests => $in_regen_pl + @files + @progs + 2);
24
25 OUTER: foreach my $file (@files) {
26     open my $fh, '<', $file or die "Can't open $file: $!";
27     1 while defined($_ = <$fh>) and !/Generated from:/;
28     if (eof $fh) {
29         fail("Can't find 'Generated from' line in $file");
30         next;
31     }
32     my @bad;
33     while (<$fh>) {
34         last if /ex: set ro:/;
35         unless (/^(?: \* | #)([0-9a-f]+) (\S+)$/) {
36             chomp $_;
37             fail("Bad line in $file: '$_'");
38             next OUTER;
39         }
40         my $digest = digest($2);
41         note("$digest $2");
42         push @bad, $2 unless $digest eq $1;
43     }
44     is("@bad", '', "generated $file is up to date");
45 }
46
47 foreach (@progs, 'regen.pl') {
48   system "$^X $_ --tap";
49 }
50
51 foreach ( '-y', '-j' ) {
52   system "$^X Porting/makemeta --tap $_";
53 }