summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-12-21 12:29:06 +0100
committerNicholas Clark <nick@ccl4.org>2011-12-22 09:06:45 +0100
commit48eabb99200aeda63e70ade7e9df4a309f13fe31 (patch)
treed71ec7b899ecc873065ae4171085c58978cbb9c4
parent010a5dd8d6baa5d69b81a3e52913422208de14df (diff)
downloadperl-48eabb99200aeda63e70ade7e9df4a309f13fe31.tar.gz
Add t/porting/utils.t, to test that utility scripts still compile.
Right now, without this, it's possible to pass the all the regression tests even if one has introduced syntax errors into scripts such as installperl or installman. No tests fail, so it's fair game to push the commit. Obviously this breaks installing perl, but we won't spot this. Whilst we can't easily test that the various scripts *work*, we can at least check that we've not made any trivial screw ups.
-rw-r--r--MANIFEST1
-rw-r--r--pod/perldelta.pod6
-rw-r--r--t/porting/utils.t88
3 files changed, 94 insertions, 1 deletions
diff --git a/MANIFEST b/MANIFEST
index fde94e5e39..89837932b6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5332,6 +5332,7 @@ t/porting/podcheck.t Test the POD of shipped modules is well formed
t/porting/pod_rules.t Check that various pod lists are consistent
t/porting/regen.t Check that regen.pl doesn't need running
t/porting/test_bootstrap.t Test that the instructions for test bootstrapping aren't accidentally overlooked.
+t/porting/utils.t Check that utility scripts still compile
t/README Instructions for regression tests
t/re/charset.t See if regex modifiers like /d, /u work properly
t/re/fold_grind.t See if case folding works properly
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 92672e20dd..6dbdcda26b 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -249,7 +249,11 @@ that they represent may be covered elsewhere.
=item *
-XXX
+F<t/porting/utils.t> now tests that various utility scripts compile cleanly.
+During development, this avoids the embarrassment of inadvertently pushing a
+commit which breaks code which isn't otherwise tested by the regression test
+suite. For example, F<installperl> and F<installman>, needed by
+C<make install>, are tested here.
=back
diff --git a/t/porting/utils.t b/t/porting/utils.t
new file mode 100644
index 0000000000..30ffaf8aea
--- /dev/null
+++ b/t/porting/utils.t
@@ -0,0 +1,88 @@
+#!./perl -w
+
+# What does this test?
+# This checks that all the perl "utils" don't have embarrassing syntax errors
+#
+# Why do we test this?
+# Right now, without this, it's possible to pass the all the regression tests
+# even if one has introduced syntax errors into scripts such as installperl
+# or installman. No tests fail, so it's fair game to push the commit.
+# Obviously this breaks installing perl, but we won't spot this.
+# Whilst we can't easily test that the various scripts *work*, we can at least
+# check that we've not made any trivial screw ups.
+#
+# It's broken - how do I fix it?
+# Presumably it's failed because some (other) code that you changed was (also)
+# used by one of the utility scripts. So you'll have to manually test that
+# script.
+
+BEGIN {
+ @INC = '..' if -f '../TestInit.pm';
+}
+use TestInit qw(T); # T is chdir to the top level
+use strict;
+
+require 't/test.pl';
+
+my @maybe;
+
+open my $fh, '<', 'MANIFEST' or die "Can't open MANIFEST: $!";
+while (<$fh>) {
+ push @maybe, $1 if m!^(Porting/\S+)!;
+}
+close $fh or die $!;
+
+open $fh, '<', 'utils.lst' or die "Can't open utils.lst: $!";
+while (<$fh>) {
+ die unless m!^(\S+)!;
+ push @maybe, $1;
+}
+close $fh or die $!;
+
+my @victims = (qw(installman installperl regen_perly.pl));
+my %excuses = (
+ 'Porting/git-deltatool' => 'Git::Wrapper',
+ 'Porting/podtidy' => 'Pod::Tidy',
+ );
+
+foreach (@maybe) {
+ if (/\.p[lm]$/) {
+ push @victims, $_;
+ } elsif ($_ ne 'x2p/a2p') {
+ # test_prep doesn't (yet) have a dependency on a2p, so it seems a bit
+ # silly adding one (and forcing it to be built) just so that we can open
+ # it and determine that it's *not* a perl program, and hence of no
+ # further interest to us.
+ open $fh, '<', $_ or die "Can't open '$_': $!";
+ my $line = <$fh>;
+ if ($line =~ m{^#!(?:\S*|/usr/bin/env\s+)perl}) {
+ push @victims, $_;
+ } else {
+ print "# $_ isn't a Perl script\n";
+ }
+ }
+}
+
+printf "1..%d\n", scalar @victims;
+
+foreach my $victim (@victims) {
+ SKIP: {
+ # Not clear to me *why* it needs the BEGIN block, given what it
+ # does, but not in an easy position to change it.
+ skip("$victim executes code in a BEGIN block which fails for empty \@ARGV")
+ if $victim eq 'utils/cpanp-run-perl';
+
+ skip ("$victim uses $excuses{$victim}, so can't test with just core modules")
+ if $excuses{$victim};
+
+ my $got = runperl(switches => ['-c'], progfile => $victim, stderr => 1);
+ is($got, "$victim syntax OK\n", "$victim compiles");
+ }
+}
+
+# Local variables:
+# cperl-indent-level: 4
+# indent-tabs-mode: nil
+# End:
+#
+# ex: set ts=8 sts=4 sw=4 et: