ExtUtils::ParseXS: Test All @INC Derived typemap Locations
authorMike Sheldrake <mike@sheldrake.net>
Wed, 10 Aug 2011 06:15:15 +0000 (08:15 +0200)
committerSteffen Mueller <smueller@cpan.org>
Wed, 10 Aug 2011 13:26:08 +0000 (15:26 +0200)
The ExtUtils::ParseXS tests would sometime fail to locate some
core Perl typemaps in @INC. This fixes CPAN RT #70047.

Patch slightly modified by Steffen Mueller.
Includes the mandatory version bump to a development version.

dist/ExtUtils-ParseXS/Changes
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
dist/ExtUtils-ParseXS/t/101-standard_typemap_locations.t

index 2c32803..b721f85 100644 (file)
@@ -1,5 +1,10 @@
 Revision history for Perl extension ExtUtils::ParseXS.
 
+3.02_01 - ...
+
+  - Test fix: Try all @INC-derived typemap locations. (CPAN RT #70047)
+    [Mike Sheldrake]
+
 3.02 - Thu Aug  4 18:19:00 CET 2011
 
   - Test fix: Use File::Spec->catfile instead of catdir where appropriate.
index bb39bf3..503ab8d 100644 (file)
@@ -35,7 +35,7 @@ our @EXPORT_OK = qw(
   process_file
   report_error_count
 );
-our $VERSION = '3.02';
+our $VERSION = '3.02_01';
 $VERSION = eval $VERSION if $VERSION =~ /_/;
 
 # The scalars in the line below remain as 'our' variables because pulling
index e9e7e59..3b89706 100644 (file)
@@ -17,7 +17,20 @@ use ExtUtils::ParseXS::Utilities qw(
         skip "No lib/ExtUtils/ directories under directories in \@INC",
         1
         unless @stl > 9;
-        ok( -f $stl[-10],
+
+        # We check only as many location entries from the start of the array
+        # (where the @INC-related entries are) as there are entries from @INC.
+        # We manage to do that by stopping when we find the "updir" related
+        # entries, which we assume is never contained in a default @INC entry.
+        my $max = $#INC;
+        $max = $#stl if $#stl < $max;
+        foreach my $i (0.. $max) {
+          $max = $i, last if $stl[$i] =~ /\Q$updir\E/;
+        }
+
+        my $updir = File::Spec->updir;
+        ok(
+            ( 0 < (grep -f $_, @stl[0..$max]) ),
             "At least one typemap file exists underneath \@INC directories"
         );
     }