summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-09-23 16:30:22 +0200
committerNicholas Clark <nick@ccl4.org>2011-09-24 09:34:04 +0200
commit6692294e17e0b71a5e4a776313e0c3ac739a3d06 (patch)
tree888b968ca55b2f4f7d71c903f86049f80d0b8e1e
parente1bac1195b4fb97ca62dff9ca5031b71a69f21c1 (diff)
downloadperl-6692294e17e0b71a5e4a776313e0c3ac739a3d06.tar.gz
Add t/porting/checkcfgvar.t to run Porting/checkcfgvar.pl as a test.
Add TAP generation and a --tap option to Porting/checkcfgvar.pl. In checkcfgvar.t, document its purpose, and the likely way to fix the problems that it has flagged up. This is a prototype before adding similar instructions to the other t/porting tests.
-rw-r--r--MANIFEST1
-rwxr-xr-xPorting/checkcfgvar.pl24
-rw-r--r--pod/perldelta.pod4
-rw-r--r--t/porting/checkcfgvar.t29
4 files changed, 53 insertions, 5 deletions
diff --git a/MANIFEST b/MANIFEST
index 8a0a1da31c..4d5c2cf58c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5123,6 +5123,7 @@ t/porting/authors.t Check that all authors have been acknowledged
t/porting/bincompat.t Check that {non_,}bincompat_options are ordered
t/porting/buildtoc.t Check that various pod lists are consistent
t/porting/checkcase.t Check whether we are case-insensitive-fs-friendly
+t/porting/checkcfgvar.t Check that all config.sh-like files are good
t/porting/cmp_version.t Test whether all changed module files have their VERSION bumped
t/porting/diag.t Test completeness of perldiag.pod
t/porting/dual-life.t Check that dual-life bins are in utils/
diff --git a/Porting/checkcfgvar.pl b/Porting/checkcfgvar.pl
index 9807cdf111..e6a819fbeb 100755
--- a/Porting/checkcfgvar.pl
+++ b/Porting/checkcfgvar.pl
@@ -24,11 +24,14 @@ use Getopt::Long;
my $opt_l = 0;
my $opt_r = 0;
my $default;
+my $tap = 0;
+my $test;
GetOptions (
"help|?" => sub { usage (0); },
"l|list!" => \$opt_l,
"regen" => \$opt_r,
"default=s" => \$default,
+ "tap" => \$tap,
) or usage (1);
require 'regen/regen_lib.pl' if $opt_r;
@@ -84,6 +87,8 @@ my %MANIFEST;
close $fh;
}
+printf "1..%d\n", 2 * @CFG if $tap;
+
for my $cfg (sort @CFG) {
unless (exists $MANIFEST{$cfg}) {
print STDERR "[skipping not-expected '$cfg']\n";
@@ -127,10 +132,16 @@ for my $cfg (sort @CFG) {
}
close $fh;
+ ++$test;
my $missing;
- if ($cfg eq 'configure.com'
- || join("", @{$lines[1]}) eq join("", sort @{$lines[1]})) {
- # All is good with the world.
+ if ($cfg eq 'configure.com') {
+ print "ok $test # skip $cfg doesn't need to be sorted\n"
+ if $tap;
+ } elsif (join("", @{$lines[1]}) eq join("", sort @{$lines[1]})) {
+ print "ok $test - $cfg sorted\n"
+ if $tap;
+ } elsif ($tap) {
+ print "not ok $test - $cfg is not sorted\n";
} elsif ($opt_r || $opt_l) {
# A reference to an empty array is true, hence this flags the
# file for later attention by --regen and --list, even if
@@ -145,8 +156,11 @@ for my $cfg (sort @CFG) {
push @$missing, $v unless exists $cfg{$v};
}
+ ++$test;
if ($missing) {
- if ($opt_l) {
+ if ($tap) {
+ print "not ok $test - $cfg missing keys @$missing\n";
+ } elsif ($opt_l) {
# print the name once, however many problems
print "$cfg\n";
} elsif ($opt_r && $cfg ne 'configure.com') {
@@ -164,5 +178,7 @@ for my $cfg (sort @CFG) {
} else {
print "$cfg: missing '$_'\n" foreach @$missing;
}
+ } elsif ($tap) {
+ print "ok $test - $cfg has no missing keys\n";
}
}
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 9c170d74d6..ba6590513c 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -242,7 +242,9 @@ that they represent may be covered elsewhere.
=item *
-XXX
+F<t/porting/checkcfgvar.t> now tests that all config.sh-style files are
+complete. These are used by the various non-*nix to generate their
+F<config.h>, and an incomplete input file will generate invalid output.
=back
diff --git a/t/porting/checkcfgvar.t b/t/porting/checkcfgvar.t
new file mode 100644
index 0000000000..10eab2d01f
--- /dev/null
+++ b/t/porting/checkcfgvar.t
@@ -0,0 +1,29 @@
+#!./perl -w
+
+# What does this test?
+# This uses Porting/checkcfgvar.pl to check that none of the config.sh-like
+# files are missing any entries.
+#
+# Why do we test this?
+# We need them to be complete when we ship a release, and this way we catch
+# problems as early as possible. (Instead of creating the potential for yet
+# another last-minute job for the release manager). If a config file for a
+# platform is incomplete, it can't be used to correctly regenerate config.h,
+# because missing values result in invalid C code. We keep the files sorted
+# as it makes it easy to automate adding defaults.
+#
+# It's broken - how do I fix it?
+# The most likely reason that the test failed is because you've just added
+# a new entry to Configure, config.sh and config_h.SH but nowhere else.
+# Run something like:
+# perl Porting/checkcfgvar.pl --regen --default=undef
+# (the correct default might not always be undef) to do most of the work, and
+# then hand-edit configure.com (as that's not automated).
+# If this changes uconfig.sh, you'll also need to run perl regen/uconfig_h.pl
+
+BEGIN {
+ @INC = '..' if -f '../TestInit.pm';
+}
+use TestInit qw(T A); # T is chdir to the top level, A makes paths absolute
+
+system "$^X Porting/checkcfgvar.pl --tap";