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