Updated XSLoader to CPAN version 0.15
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Wed, 18 May 2011 17:53:16 +0000 (18:53 +0100)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Thu, 9 Jun 2011 11:17:08 +0000 (12:17 +0100)
  [DELTA]

  0.15 - 2011.04.17 - SAPER #PerlQA2011
    - [DIST] CPAN-RT#54456: Set INSTALLDIRS to "site" when installed on
      Perl 5.11+ (thanks to Todd Rinaldo).
    - [DOC] Document a known bug under Perl 5.8.4 and 5.8.5.
    - [TESTS] Fixed tests to pass under Perl 5.8.4 and 5.8.5.

  0.14 - 2011.04.16 - SAPER #PerlQA2011
    - [CODE] Updated from bleadperl:
       - XSLoader::load() with no arguments can use caller to find
         a default package (Nicholas Clark).
       - Avoid defining a full XSLoader::bootstrap_inherit post 5.6,
         as it's not needed (Nicholas Clark).
       - Small optimisation: for the generated XSLoader.pm, avoid a
         runtime lexical which is constant (Nicholas Clark).
    - [TESTS] Updated from bleadperl, solving RT-CPAN #54132, #61332.
    - [TESTS] Fixed tests for old Perls.
    - [TESTS] Added t/00-load.t and t/01-api.t, to provide basic tests
      when the main ones are skipped.

Porting/Maintainers.pl
dist/XSLoader/Makefile.PL
dist/XSLoader/XSLoader_pm.PL
dist/XSLoader/t/XSLoader.t

index d321877..3039731 100755 (executable)
@@ -2071,7 +2071,7 @@ use File::Glob qw(:case);
     'XSLoader' =>
        {
        'MAINTAINER'    => 'saper',
-       'DISTRIBUTION'  => 'SAPER/XSLoader-0.10.tar.gz',
+       'DISTRIBUTION'  => 'SAPER/XSLoader-0.15.tar.gz',
        'FILES'         => q[dist/XSLoader],
        'EXCLUDED'      => [ qr{^eg/},
                             qw{t/pod.t
index a06d7cc..bb92d84 100644 (file)
@@ -27,13 +27,18 @@ CHANGE_WARN
 # In case the empty lib/ directory was not created.
 mkdir 'lib', 0755 unless $ENV{PERL_CORE};
 
+# starting with Perl 5.11, "site" and "vendor" directories finally are
+# before "perl" (core) in @INC, thus allowing dual-life modules to be
+# updated without the need to overwrite the old version
+my $installdirs = $] < 5.011 ? "perl" : "site";
+
 WriteMakefile(
     NAME            => $PACKAGE,
     LICENSE         => 'perl',
     AUTHOR          => 'Sebastien Aperghis-Tramoni <sebastien@aperghis.net>',
     VERSION_FROM    => 'XSLoader_pm.PL',
     ABSTRACT_FROM   => 'XSLoader_pm.PL',
-    INSTALLDIRS     => 'perl',
+    INSTALLDIRS     => $installdirs,
     PL_FILES        => { 'XSLoader_pm.PL'  => 'XSLoader.pm' },
     PM              => { 'XSLoader.pm' => '$(INST_ARCHLIB)/XSLoader.pm' },
     PREREQ_PM       => {
index 0738fa5..64ebcc2 100644 (file)
@@ -8,7 +8,7 @@ print OUT <<'EOT';
 
 package XSLoader;
 
-$VERSION = "0.13";
+$VERSION = "0.15";
 
 #use strict;
 
@@ -29,9 +29,9 @@ sub load {
     my ($module, $modlibname) = caller();
 
     if (@_) {
-       $module = $_[0];
+        $module = $_[0];
     } else {
-       $_[0] = $module;
+        $_[0] = $module;
     }
 
     # work with static linking too
@@ -63,7 +63,7 @@ EOT
 print OUT <<'EOT';
     my $modpname = join('/',@modparts);
     my $c = @modparts;
-    $modlibname =~ s,[\\/][^\\/]+$,, while $c--;       # Q&D basename
+    $modlibname =~ s,[\\/][^\\/]+$,, while $c--;    # Q&D basename
 EOT
 
 my $dl_dlext = quotemeta($Config::Config{'dlext'});
@@ -139,7 +139,7 @@ print OUT <<'EOT';
 }
 EOT
 
-# Can't test with DynaLoader->can('bootstrap_inherit' when building in the
+# Can't test with DynaLoader->can('bootstrap_inherit') when building in the
 # core, as XSLoader gets built before DynaLoader.
 
 if ($] >= 5.006) {
@@ -181,7 +181,7 @@ XSLoader - Dynamically load C libraries into Perl code
 
 =head1 VERSION
 
-Version 0.13
+Version 0.15
 
 =head1 SYNOPSIS
 
@@ -392,6 +392,12 @@ may have much more overhead than running the same extensions after
 C<make install>.
 
 
+=head1 KNOWN BUGS
+
+The new simpler way to call C<XSLoader::load()> with no arguments at all
+does not work on Perl 5.8.4 and 5.8.5.
+
+
 =head1 BUGS
 
 Please report any bugs or feature requests via the perlbug(1) utility.
@@ -414,7 +420,7 @@ Previous maintainer was Michael G Schwern <schwern@pobox.com>.
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright (C) 1990-2007 by Larry Wall and others.
+Copyright (C) 1990-2011 by Larry Wall and others.
 
 This program is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
index 0cac1f2..bf02e48 100644 (file)
@@ -5,12 +5,13 @@ use Config;
 
 my $db_file;
 BEGIN {
-    eval "use Test::More";
-    if ($@) {
+    if (not eval "use Test::More; 1") {
         print "1..0 # Skip: Test::More not available\n";
         die "Test::More not available\n";
     }
 
+    plan(skip_all => "these tests needs Perl 5.5+") if $] < 5.005;
+
     use Config;
     foreach (qw/SDBM_File GDBM_File ODBM_File NDBM_File DB_File/) {
         if ($Config{extensions} =~ /\b$_\b/) {
@@ -40,20 +41,31 @@ can_ok( 'XSLoader' => 'load' );
 can_ok( 'XSLoader' => 'bootstrap_inherit' );
 
 # Check error messages
-foreach (['Thwack', 'package Thwack; XSLoader::load(); 1'],
-        ['Zlott', 'package Thwack; XSLoader::load("Zlott"); 1'],
-       ) {
-    my ($should_load, $codestr) = @$_;
-    is(eval $codestr, undef, "eval '$codestr' should die");
+my @cases = (
+    [ 'Thwack', 'package Thwack; XSLoader::load(); 1'        ],
+    [ 'Zlott' , 'package Thwack; XSLoader::load("Zlott"); 1' ],
+);
+
+for my $case (@cases) {
+    my ($should_load, $codestr) = @$case;
+    my $diag;
 
+    # determine the expected diagnostic
     if ($Config{usedl}) {
-       like( $@, qr/^Can't locate loadable object for module $should_load in \@INC/,
-             "calling XSLoader::load() under a package with no XS part" );
-    }
-    else {
-       like( $@, qr/^Can't load module $should_load, dynamic loading not available in this perl./,
-             "calling XSLoader::load() under a package with no XS part" );
+        if ($case->[0] eq "Thwack" and ($] == 5.008004 or $] == 5.008005)) {
+            # these versions had bugs with chained C<goto &>
+            $diag = "Usage: DynaLoader::bootstrap\\(module\\)";
+        } else {
+            # normal diagnostic for a perl with dynamic loading
+            $diag = "Can't locate loadable object for module $should_load in \@INC";
+        }
+    } else {
+        # a perl with no dynamic loading
+        $diag = "Can't load module $should_load, dynamic loading not available in this perl.";
     }
+
+    is(eval $codestr, undef, "eval '$codestr' should die");
+    like($@, qr/^$diag/, "calling XSLoader::load() under a package with no XS part");
 }
 
 # Now try to load well known XS modules
@@ -65,10 +77,10 @@ for my $module (sort keys %modules) {
     local $SIG{__WARN__} = sub { $warnings = $_[0] };
 
     SKIP: {
-        skip "$module not available", 4 if $extensions !~ /\b$module\b/;
+        skip "$module not available", 3 if $extensions !~ /\b$module\b/;
 
         eval qq{ package $module; XSLoader::load('$module', "12345678"); };
-        like( $@, "/^$module object version \\S+ does not match bootstrap parameter (?:12345678|0)/",
+        like( $@, "/^$module object version \\S+ does not match bootstrap parameter 12345678/",
                 "calling XSLoader::load() with a XS module and an incorrect version" );
 
         eval qq{ package $module; XSLoader::load('$module'); };