This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix O_CREAT without O_TRUNC in cpan/autodie/t/utf8_open.t
[perl5.git] / t / porting / regen.t
CommitLineData
3879ea51
NC
1#!./perl -w
2
3# Verify that all files generated by perl scripts are up to date.
4
3879ea51 5BEGIN {
208c2b59 6 @INC = '..' if -f '../TestInit.pm';
3879ea51 7}
208c2b59 8use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
3879ea51
NC
9use strict;
10
c24c946d
NC
11require 'regen/regen_lib.pl';
12require 't/test.pl';
13$::NO_ENDING = $::NO_ENDING = 1;
14
b511b76c
CB
15if ( $^O eq "VMS" ) {
16 skip_all( "- regen.pl needs porting." );
17}
18
7afc9753 19my $tests = 26; # I can't see a clean way to calculate this automatically.
c24c946d 20
0daf6d09
NC
21my %skip = ("regen_perly.pl" => [qw(perly.act perly.h perly.tab)],
22 "regen/keywords.pl" => [qw(keywords.c keywords.h)],
23 "regen/uconfig_h.h" => [qw(uconfig.h)],
24 );
25
26my @files = map {@$_} sort values %skip;
27
28open my $fh, '<', 'regen.pl'
29 or die "Can't open regen.pl: $!";
30
31while (<$fh>) {
32 last if /^__END__/;
33}
34die "Can't find __END__ in regen.pl"
35 if eof $fh;
36
37foreach (qw(embed_lib.pl regen_lib.pl uconfig_h.pl
38 regcharclass_multi_char_folds.pl),
39 map {chomp $_; $_} <$fh>) {
40 ++$skip{"regen/$_"};
41}
42
43close $fh
44 or die "Can't close regen.pl: $!";
45
46my @progs = grep {!$skip{$_}} <regen/*.pl>;
47push @progs, 'regen.pl', map {"Porting/makemeta $_"} qw(-j -y);
48
49plan (tests => $tests + @files + @progs);
c24c946d
NC
50
51OUTER: foreach my $file (@files) {
52 open my $fh, '<', $file or die "Can't open $file: $!";
53 1 while defined($_ = <$fh>) and !/Generated from:/;
54 if (eof $fh) {
55 fail("Can't find 'Generated from' line in $file");
56 next;
57 }
58 my @bad;
59 while (<$fh>) {
60 last if /ex: set ro:/;
61 unless (/^(?: \* | #)([0-9a-f]+) (\S+)$/) {
62 chomp $_;
63 fail("Bad line in $file: '$_'");
64 next OUTER;
65 }
66 my $digest = digest($2);
67 note("$digest $2");
68 push @bad, $2 unless $digest eq $1;
69 }
70 is("@bad", '', "generated $file is up to date");
71}
3879ea51 72
0daf6d09
NC
73foreach (@progs) {
74 my $command = "$^X $_ --tap";
75 system $command
76 and die "Failed to run $command: $?";
bfc0a3e7 77}