From: Nicholas Clark Date: Fri, 9 Oct 2009 18:24:56 +0000 (+0200) Subject: Add a test for the bootstrap rules for tests in t/ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=66cad4abfc5d793c52a82bd17877e19bb8276665;p=p5sagit%2Fp5-mst-13.2.git Add a test for the bootstrap rules for tests in t/ --- diff --git a/MANIFEST b/MANIFEST index 5f7efa3..a59fbc7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4440,6 +4440,7 @@ t/porting/diag.t Test completeness of perldiag.pod t/porting/maintainers.t Test that Porting/Maintaners.pl is up to date t/porting/manifest.t Test that this MANIFEST file is well formed t/porting/podcheck.t Test the POD of shipped modules is well formed +t/porting/test_bootstrap.t Test that the instructions for test bootstrapping aren't accidentally overlooked. t/README Instructions for regression tests t/re/pat_advanced.t See if advanced esoteric patterns work t/re/pat_advanced_thr.t See if advanced esoteric patterns work in another thread diff --git a/t/porting/test_bootstrap.t b/t/porting/test_bootstrap.t new file mode 100644 index 0000000..a1bd63d --- /dev/null +++ b/t/porting/test_bootstrap.t @@ -0,0 +1,47 @@ +#!/perl -w +use strict; + +# See "Writing a test" in perlhack.pod for the instructions about the order that +# testing directories run, and which constructions should be avoided in the +# early tests. + +# This regression tests ensures that the rules aren't accidentally overlooked. + +require './test.pl'; + +plan('no_plan'); + +open my $fh, '<', '../MANIFEST' or die "Can't open MANIFEST: $!"; + +# Three tests in t/comp need to use require or use to get their job done: +my %exceptions = (hints => "require './test.pl'", + parser => 'use DieDieDie', + proto => 'use strict', + ); + +while (my $file = <$fh>) { + next unless $file =~ s!^t/!!; + chomp $file; + $file =~ s/\s+.*//; + next unless $file =~ m!\.t$!; + + local $/; + open my $t, '<', $file or die "Can't open $file: $!"; + my $contents = <$t>; + # Make sure that we don't match ourselves + unlike($contents, qr/use\s+Test::More/, "$file doesn't use Test::\QMore"); + next unless $file =~ m!^base/! or $file =~ m!^comp!; + + # Remove only the excepted constructions for the specific files. + if ($file =~ m!comp/(.*)\.t! && $exceptions{$1}) { + my $allowed = $exceptions{$1}; + $contents =~ s/\Q$allowed//gs; + } + + # All uses of use are allowed in t/comp/use.t + unlike($contents, qr/^\s*use\s+/m, "$file doesn't use use") + unless $file eq 'comp/use.t'; + # All uses of require are allowed in t/comp/require.t + unlike($contents, qr/^\s*require\s+/m, "$file doesn't use require") + unless $file eq 'comp/require.t' +}