Author: dagolden
Date: Fri Aug  7 11:02:01 2009
New Revision: 13174

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/t/lib/MBTest.pm
   Module-Build/trunk/t/xs.t

Log:
Fixed failing xs.t if /tmp is mounted noexec (RT#47331)



Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Fri Aug  7 11:02:01 2009
@@ -2,11 +2,14 @@
 
 0.34_03 - 
 
+ Bug fixes:
+ - Fixed failing xs.t if /tmp is mounted noexec (RT#47331) [David Golden]
+
 0.34_02 - Sun Jul 26 22:50:40 EDT 2009
 
  Bug-fixes:
  - Bundled Module::Build::Version updated to bring into sync with CPAN
-   version.pm 0.77
+   version.pm 0.77 [John Peacock]
 
 0.34_01 - Sat Jul 18 16:32:09 EDT 2009
 

Modified: Module-Build/trunk/t/lib/MBTest.pm
==============================================================================
--- Module-Build/trunk/t/lib/MBTest.pm  (original)
+++ Module-Build/trunk/t/lib/MBTest.pm  Fri Aug  7 11:02:01 2009
@@ -123,8 +123,10 @@
 
 # Setup a temp directory 
 sub tmpdir { 
+  my ($self, $usr_tmp) = @_;
   return File::Temp::tempdir( 'MB-XXXXXXXX', 
-    CLEANUP => 1, DIR => $ENV{PERL_CORE} ? Cwd::cwd : File::Spec->tmpdir
+    CLEANUP => 1, DIR => $ENV{PERL_CORE} ? Cwd::cwd : 
+                         $usr_tmp        ? $usr_tmp : File::Spec->tmpdir 
   );
 }
 
@@ -200,7 +202,20 @@
   my $have_c_compiler;
   stderr_of( sub {$have_c_compiler = $mb->have_c_compiler} );
 
-  return ($have_c_compiler, $mb->feature('C_support'));
+  # check noexec tmpdir
+  my $tmp_exec;
+  if ( $have_c_compiler ) {
+    my $dir = MBTest->tmpdir;
+    my $c_file = File::Spec->catfile($dir,'test.c');
+    open my $fh, ">", $c_file;
+    print {$fh} "int main() { return 0; }\n";
+    close $fh;
+    my $exe = $mb->cbuilder->link_executable(
+      objects => $mb->cbuilder->compile( source => $c_file )
+    );
+    $tmp_exec = 0 == system( $exe );
+  }
+  return ($have_c_compiler, $mb->feature('C_support'), $tmp_exec);
 }
 
 sub have_module {

Modified: Module-Build/trunk/t/xs.t
==============================================================================
--- Module-Build/trunk/t/xs.t   (original)
+++ Module-Build/trunk/t/xs.t   Fri Aug  7 11:02:01 2009
@@ -6,8 +6,10 @@
 use Module::Build;
 use Config;
 
+my $tmp;
+
 {
-  my ($have_c_compiler, $C_support_feature) = check_compiler();
+  my ($have_c_compiler, $C_support_feature, $tmp_exec) = check_compiler();
 
   if (! $C_support_feature) {
     plan skip_all => 'C_support not enabled';
@@ -20,6 +22,8 @@
   } else {
     plan tests => 23;
   }
+  require Cwd;
+  $tmp = MBTest->tmpdir( $tmp_exec ? undef : Cwd::cwd );
 }
 
 ensure_blib('Module::Build');
@@ -27,9 +31,6 @@
 
 #########################
 
-
-my $tmp = MBTest->tmpdir;
-
 use DistGen;
 my $dist = DistGen->new( dir => $tmp, xs => 1 );
 $dist->regen;

Reply via email to