- add limited tests for Imager::ExtUtils
authorTony Cook <tony@develop=help.com>
Fri, 12 Dec 2008 09:40:19 +0000 (09:40 +0000)
committerTony Cook <tony@develop=help.com>
Fri, 12 Dec 2008 09:40:19 +0000 (09:40 +0000)
 - make Imager::ExtUtils->includes use an absolute path, since
   a relative path could cause failures using Inline::C.
   http://rt.cpan.org/Ticket/Display.html?id=37353

Changes
MANIFEST
lib/Imager/ExtUtils.pm
t/t83extutil.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 9c19a32a286f9982d0bdc00ee8e4a49d9b2b8127..861ae7484c5514cfada5dd57ecfa9d33cf978947 100644 (file)
--- a/Changes
+++ b/Changes
@@ -15,6 +15,12 @@ Bug fixes:
  - write out the image size in bytes field of a BMP correctly.
    http://rt.cpan.org/Ticket/Display.html?id=41406
 
+ - add limited tests for Imager::ExtUtils
+
+ - make Imager::ExtUtils->includes use an absolute path, since
+   a relative path could cause failures using Inline::C.
+   http://rt.cpan.org/Ticket/Display.html?id=37353
+
 Imager 0.66 - 22 April 2008
 ===========
 
index 1fb3d1de63ca39da0b6d09947b7b7f29753b04aa..0658c5366c598034115a1152b23ca42e4f617988 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -268,6 +268,7 @@ t/t75polyaa.t
 t/t80texttools.t        Test text wrapping
 t/t81hlines.t          Test hlines.c
 t/t82inline.t           Test Inline::C integration
+t/t83extutil.t         Test Imager::ExtUtils
 t/t90cc.t
 t/t91pod.t             Test POD with Test::Pod
 t/t92samples.t
index 93a63f519c3bea91e06ce841095712930b5773cb..a43a7bc418da5828db76f19955f6e5ee56785891 100644 (file)
@@ -1,9 +1,10 @@
 package Imager::ExtUtils;
 use strict;
+use File::Spec;
 
 use vars qw($VERSION);
 
-$VERSION = "1.001";
+$VERSION = "1.002";
 
 =head1 NAME
 
@@ -27,9 +28,13 @@ Returns the base directory where Imager is installed.
 
 # figure out where Imager is installed
 sub base_dir {
-  for my $dir (@INC) {
-    if (-e "$dir/Imager.pm") {
-      return $dir;
+  for my $inc_dir (@INC) {
+    if (-e "$inc_dir/Imager.pm") {
+      my $base_dir = $inc_dir;
+      unless (File::Spec->file_name_is_absolute($base_dir)) {
+       $base_dir = File::Spec->rel2abs($base_dir);
+      }
+      return $base_dir;
     }
   }
 
diff --git a/t/t83extutil.t b/t/t83extutil.t
new file mode 100644 (file)
index 0000000..15080f3
--- /dev/null
@@ -0,0 +1,32 @@
+#!perl -w
+use strict;
+use Test::More tests => 6;
+use File::Spec;
+
+{ # RT 37353
+  local @INC = @INC;
+
+  unshift @INC, File::Spec->catdir('blib', 'lib');
+  unshift @INC, File::Spec->catdir('blib', 'arch');
+  require Imager::ExtUtils;
+  my $path = Imager::ExtUtils->base_dir;
+  ok(File::Spec->file_name_is_absolute($path), "check dirs absolute")
+    or print "# $path\n";
+}
+
+{ # includes
+  my $includes = Imager::ExtUtils->includes;
+  ok($includes =~ s/^-I//, "has the -I");
+  ok(-e File::Spec->catfile($includes, "imext.h"), "found a header");
+}
+
+{ # typemap
+  my $typemap = Imager::ExtUtils->typemap;
+  ok($typemap, "got a typemap path");
+  ok(-f $typemap, "it exists");
+  open TYPEMAP, "< $typemap";
+  my $tm_content = do { local $/; <TYPEMAP>; };
+  close TYPEMAP;
+  cmp_ok($tm_content, '=~', "Imager::Color\\s+T_PTROBJ",
+        "it seems to be the right file");
+}