This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add t/porting/globvar.t, to sanity test globvar.sym on a *nix platform.
authorNicholas Clark <nick@ccl4.org>
Fri, 19 Aug 2011 10:15:38 +0000 (12:15 +0200)
committerNicholas Clark <nick@ccl4.org>
Tue, 23 Aug 2011 09:28:55 +0000 (11:28 +0200)
This adds to makedef.pl a new platform, "test".

Hopefully this change will catch most problems that previously had resulted
in build failures on Win32.

MANIFEST
Porting/exercise_makedef.pl
makedef.pl
pod/perldelta.pod
t/porting/globvar.t [new file with mode: 0644]

index 7521387..3d33e06 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5084,6 +5084,7 @@ t/porting/dual-life.t             Check that dual-life bins are in utils/
 t/porting/exec-bit.t           Check that exec-bit bins are identified
 t/porting/filenames.t          Check the MANIFEST for filename portability.
 t/porting/FindExt.t            Test win32/FindExt.pm
+t/porting/globvar.t            Check that globvar.sym is sane
 t/porting/known_pod_issues.dat Data file for porting/podcheck.t
 t/porting/maintainers.t                Test that Porting/Maintainers.pl is up to date
 t/porting/manifest.t           Test that this MANIFEST file is well formed
index 3588192..03b2061 100644 (file)
@@ -48,7 +48,7 @@ $SIG{INT} = sub { die }; # Trigger END processing
     close $out or die "Can't close $mpm: $!";
 }
 
-my @args = (platform => [map {"PLATFORM=$_"} qw(aix win32 wince os2 netware vms)],
+my @args = (platform => [map {"PLATFORM=$_"} qw(aix win32 wince os2 netware vms test)],
            cflags => ['', 'CCFLAGS=-Dperl=rules -Dzzz'],
            Deq => ['', '-Dbeer=foamy'],
            D => ['', '-DPERL_IMPLICIT_SYS'],
index 318202f..076b39a 100644 (file)
@@ -55,7 +55,7 @@ while (@ARGV) {
 }
 
 {
-    my @PLATFORM = qw(aix win32 wince os2 netware vms);
+    my @PLATFORM = qw(aix win32 wince os2 netware vms test);
     my %PLATFORM;
     @PLATFORM{@PLATFORM} = ();
 
@@ -81,7 +81,7 @@ process_cc_flags(@Config{qw(ccflags optimize)})
 # minimal configs that don't include any of those options.
 
 my @options = sort(Config::bincompat_options(), Config::non_bincompat_options());
-print STDERR "Options: (@options)\n";
+print STDERR "Options: (@options)\n" unless $ARGS{PLATFORM} eq 'test';
 $define{$_} = 1 foreach @options;
 
 my %exportperlmalloc =
@@ -136,7 +136,8 @@ if ($define{USE_ITHREADS} && $ARGS{PLATFORM} ne 'win32' && $^O ne 'darwin') {
 
 # perl.h logic duplication ends
 
-print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n";
+print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n"
+     unless $ARGS{PLATFORM} eq 'test';
 
 my $sym_ord = 0;
 my %ordinal;
index 86e179d..5143507 100644 (file)
@@ -344,7 +344,10 @@ L</Modules and Pragmata>.
 
 =item *
 
-XXX
+F<t/porting/globvar.t> has been added, to run a sanity check on F<globar.sym>.
+F<globar.sym> is not needed on most *nix platforms, but is for Win32, hence
+previously was it was possible to inadvertently commit changes that worked
+perfectly locally, but broke the build on Win32.
 
 =back
 
diff --git a/t/porting/globvar.t b/t/porting/globvar.t
new file mode 100644 (file)
index 0000000..23f5c48
--- /dev/null
@@ -0,0 +1,70 @@
+#!perl -w
+
+use TestInit qw(T);
+use strict;
+use Config;
+
+require 't/test.pl';
+
+skip_all("Code to read symbols not ported to $^O")
+    if $^O eq 'VMS' or $^O eq 'Win32';
+
+# Not investigated *why* we don't export these, but we don't, and we've not
+# received any bug reports about it causing problems:
+my %skip = map { ("PL_$_", 1) }
+    qw(
+         DBcv bitcount cshname force_link_funcs generation lastgotoprobe
+         latin1_lc mod_latin1_uc modcount no_symref_sv timesbuf uudmap
+         watchaddr watchok
+     );
+
+my $trial = "nm globals$Config{_o} 2>&1";
+my $yes = `$trial`;
+
+skip_all("Could not run `$trial`") if $?;
+
+my $defined = qr/^[0-9a-fA-F]{8,16}\s+[^Uu]\s+_?/m;
+
+skip_all("Could not spot definition of PL_Yes in output of `$trial`")
+    unless $yes =~ /${defined}PL_Yes/m;
+
+my %exported;
+open my $fh, '-|', $^X, '-Ilib', './makedef.pl', 'PLATFORM=test'
+    or die "Can't run makedef.pl";
+
+while (<$fh>) {
+    next unless /^PL_/;
+    chomp;
+    ++$exported{$_};
+}
+
+close $fh or die "Problem running makedef.pl";
+
+my %unexported;
+
+foreach my $file (map {$_ . $Config{_o}} qw(globals regcomp)) {
+    open $fh, '-|', 'nm', $file
+       or die "Can't run nm $file";
+
+    while (<$fh>) {
+       next unless /$defined(PL_\S+)/;
+       if (delete $exported{$1}) {
+           note("Seen definition of $1");
+           next;
+       }
+       ++$unexported{$1};
+    }
+    close $fh or die "Problem running nm $file";
+}
+
+fail("Attempting to export '$_' which is never defined")
+    foreach sort keys %exported;
+
+foreach (sort keys %unexported) {
+ SKIP: {
+       skip("We don't export $_", 1) if $skip{$_};
+       fail("$_ is defined, but we do not export it");
+    }
+}
+
+done_testing();