escape the backslashes in win32 paths; print the lib dir for diagnosing mysterious...
[p5sagit/local-lib.git] / t / taint-mode.t
index f1a547f..3561e0c 100644 (file)
@@ -6,14 +6,13 @@
 
 use strict;
 use warnings;
-use Test::More;
-use File::Temp qw(tempdir tempfile);
+use Test::More tests => 1;
+use File::Temp 'tempfile';
 use Cwd;
 
-plan tests => 1;
+use lib 't/lib'; use TempDir;
 
-# Setup temp dir to serve as local lib
-my $dir1 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
+my $dir1 = mk_temp_dir('test_local_lib-XXXXX');
 
 # Set up local::lib environment using our temp dir
 require local::lib;
@@ -23,12 +22,16 @@ local::lib->import($dir1);
 # local lib to the same temp dir.
 my ($fh, $filename) = tempfile('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), UNLINK => 1);
 
+# escape backlslashes for embedding into generated script
+$dir1 =~ s/\\/\\\\/g;
+
 print $fh <<EOM;
 #!/usr/bin/perl -T
 use strict; use warnings;
 use local::lib '$dir1';
-my \$dir1 = "$dir1";
-if (grep { \$_ =~ m{^\$dir1/} } \@INC) {
+warn 'using lib dir $dir1', "\n";
+my \$dir = '$dir1';
+if (grep { m{^\\Q\$dir\\E/} } \@INC) {
   exit 0;
 }
 exit 1