Commit | Line | Data |
---|---|---|
3879ea51 NC |
1 | #!./perl -w |
2 | ||
3 | # Verify that all files generated by perl scripts are up to date. | |
4 | ||
5 | my ($in_t, $lib); | |
6 | ||
7 | BEGIN { | |
8 | $in_t = -f 'TEST' && -f '../regen.pl'; | |
9 | $lib = $in_t ? '../lib' : 'lib'; | |
10 | unshift @INC, $lib; | |
11 | } | |
12 | ||
13 | use strict; | |
14 | ||
15 | use File::Spec::Functions 'rel2abs'; | |
16 | $^X = rel2abs($^X); | |
17 | $ENV{PERL5LIB} = rel2abs($lib); | |
18 | ||
19 | chdir '..' if $in_t; | |
20 | ||
c24c946d NC |
21 | $INC[0] = 'lib'; |
22 | require 'regen/regen_lib.pl'; | |
23 | require 't/test.pl'; | |
24 | $::NO_ENDING = $::NO_ENDING = 1; | |
25 | ||
f133ac5d NC |
26 | my $in_regen_pl = 17; # I can't see a clean way to calculate this automatically. |
27 | my @files = qw(perly.act perly.h perly.tab keywords.c keywords.h); | |
ea52845d | 28 | my @progs = qw(Porting/makemeta regen/regcharclass.pl regen/mk_PL_charclass.pl); |
c24c946d | 29 | |
ea52845d | 30 | plan (tests => $in_regen_pl + @files + @progs); |
c24c946d NC |
31 | |
32 | OUTER: foreach my $file (@files) { | |
33 | open my $fh, '<', $file or die "Can't open $file: $!"; | |
34 | 1 while defined($_ = <$fh>) and !/Generated from:/; | |
35 | if (eof $fh) { | |
36 | fail("Can't find 'Generated from' line in $file"); | |
37 | next; | |
38 | } | |
39 | my @bad; | |
40 | while (<$fh>) { | |
41 | last if /ex: set ro:/; | |
42 | unless (/^(?: \* | #)([0-9a-f]+) (\S+)$/) { | |
43 | chomp $_; | |
44 | fail("Bad line in $file: '$_'"); | |
45 | next OUTER; | |
46 | } | |
47 | my $digest = digest($2); | |
48 | note("$digest $2"); | |
49 | push @bad, $2 unless $digest eq $1; | |
50 | } | |
51 | is("@bad", '', "generated $file is up to date"); | |
52 | } | |
3879ea51 | 53 | |
ea52845d | 54 | foreach (@progs, 'regen.pl') { |
25bab59b NC |
55 | system "$^X $_ --tap"; |
56 | } |