1898184e3Ssthen#!./perl -w 2898184e3Ssthen 3898184e3Ssthen# What does this test? 4898184e3Ssthen# This checks that all the perl "utils" don't have embarrassing syntax errors 5898184e3Ssthen# 6898184e3Ssthen# Why do we test this? 7898184e3Ssthen# Right now, without this, it's possible to pass the all the regression tests 8898184e3Ssthen# even if one has introduced syntax errors into scripts such as installperl 9898184e3Ssthen# or installman. No tests fail, so it's fair game to push the commit. 10898184e3Ssthen# Obviously this breaks installing perl, but we won't spot this. 11898184e3Ssthen# Whilst we can't easily test that the various scripts *work*, we can at least 12898184e3Ssthen# check that we've not made any trivial screw ups. 13898184e3Ssthen# 14898184e3Ssthen# It's broken - how do I fix it? 15898184e3Ssthen# Presumably it's failed because some (other) code that you changed was (also) 16898184e3Ssthen# used by one of the utility scripts. So you'll have to manually test that 17898184e3Ssthen# script. 18898184e3Ssthen 19898184e3SsthenBEGIN { 20898184e3Ssthen @INC = '..' if -f '../TestInit.pm'; 21898184e3Ssthen} 22898184e3Ssthenuse TestInit qw(T); # T is chdir to the top level 23898184e3Ssthenuse strict; 24898184e3Ssthen 259f11ffb7Safresh1require './t/test.pl'; 26898184e3Ssthen 27898184e3Ssthen# It turns out that, since the default @INC will include your old 5.x libs, if 28898184e3Ssthen# you have them, the Porting utils might load a library that no longer compiles 29898184e3Ssthen# clean. This actually happened, with Local::Maketext::Lexicon from a 5.10.0 30898184e3Ssthen# preventing 5.16.0-RC0 from testing successfully. This test is really only 31898184e3Ssthen# needed for porters, anyway. -- rjbs, 2012-05-10 32898184e3Ssthenfind_git_or_skip('all'); 33898184e3Ssthen 34898184e3Ssthenmy @maybe; 35898184e3Ssthen 36898184e3Ssthenopen my $fh, '<', 'MANIFEST' or die "Can't open MANIFEST: $!"; 37898184e3Ssthenwhile (<$fh>) { 38898184e3Ssthen push @maybe, $1 if m!^(Porting/\S+)!; 39898184e3Ssthen} 40898184e3Ssthenclose $fh or die $!; 41898184e3Ssthen 42898184e3Ssthenopen $fh, '<', 'utils.lst' or die "Can't open utils.lst: $!"; 43898184e3Ssthenwhile (<$fh>) { 44898184e3Ssthen die unless m!^(\S+)!; 45898184e3Ssthen push @maybe, $1; 46898184e3Ssthen $maybe[$#maybe] .= '.com' if $^O eq 'VMS'; 47898184e3Ssthen} 48898184e3Ssthenclose $fh or die $!; 49898184e3Ssthen 50*3d61058aSafresh1my @victims = (qw(installman installperl regen_perly.pl)); 51898184e3Ssthenmy %excuses = ( 52898184e3Ssthen 'Porting/git-deltatool' => 'Git::Wrapper', 53898184e3Ssthen 'Porting/podtidy' => 'Pod::Tidy', 5491f110e0Safresh1 'Porting/leakfinder.pl' => 'XS::APItest', 55898184e3Ssthen ); 56898184e3Ssthen 57898184e3Ssthenforeach (@maybe) { 58898184e3Ssthen if (/\.p[lm]$/) { 59898184e3Ssthen push @victims, $_; 60b8851fccSafresh1 } else { 61898184e3Ssthen open $fh, '<', $_ or die "Can't open '$_': $!"; 62898184e3Ssthen my $line = <$fh>; 63898184e3Ssthen if ($line =~ m{^#!(?:\S*|/usr/bin/env\s+)perl} 64898184e3Ssthen || $^O eq 'VMS' && $line =~ m{^\$ perl}) { 65898184e3Ssthen push @victims, $_; 66898184e3Ssthen } else { 67898184e3Ssthen print "# $_ isn't a Perl script\n"; 68898184e3Ssthen } 69898184e3Ssthen } 70898184e3Ssthen} 71898184e3Ssthen 72898184e3Ssthenprintf "1..%d\n", scalar @victims; 73898184e3Ssthen 74eac174f2Safresh1# Does this perl have 64 bit integers? 75eac174f2Safresh1my $has_64bit_ints = eval { pack "Q", 1 }; 76eac174f2Safresh1 77898184e3Ssthenforeach my $victim (@victims) { 78898184e3Ssthen SKIP: { 79898184e3Ssthen skip ("$victim uses $excuses{$victim}, so can't test with just core modules") 80898184e3Ssthen if $excuses{$victim}; 81898184e3Ssthen 826fb12b70Safresh1 my $got = runperl(switches => ['-c'], progfile => $victim, stderr => 1, nolib => 1); 83eac174f2Safresh1 84eac174f2Safresh1 # check to see if this script needs 64 bit integers. 85eac174f2Safresh1 if (!$has_64bit_ints and $got =~ /requires 64 bit integers/) { 86eac174f2Safresh1 skip("$victim requires 64 bit integers and this is a 32 bit Perl", 1); 87eac174f2Safresh1 } 88eac174f2Safresh1 89b8851fccSafresh1 is($got, "$victim syntax OK\n", "$victim compiles") 90b8851fccSafresh1 or diag("when executing perl with '-c $victim'"); 91898184e3Ssthen } 92898184e3Ssthen} 93898184e3Ssthen 94898184e3Ssthen# ex: set ts=8 sts=4 sw=4 et: 95