fix escaping of backslashes in win32 paths in test
[p5sagit/local-lib.git] / t / taint-mode.t
CommitLineData
24351831 1#
2# t/taint-mode.t: checks that local::lib sets up @INC correctly when
3# included in a script that has taint mode on, and is executing in an
4# environment in which local::lib has already been loaded.
5#
6
7use strict;
8use warnings;
0c1be9f3 9use Test::More tests => 1;
10use File::Temp 'tempfile';
24351831 11use Cwd;
12
0c1be9f3 13use lib 't/lib'; use TempDir;
24351831 14
0c1be9f3 15my $dir1 = mk_temp_dir('test_local_lib-XXXXX');
24351831 16
17# Set up local::lib environment using our temp dir
18require local::lib;
19local::lib->import($dir1);
20
21# Create a script that has taint mode turned on, and tries to use a
22# local lib to the same temp dir.
23my ($fh, $filename) = tempfile('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), UNLINK => 1);
24
25print $fh <<EOM;
26#!/usr/bin/perl -T
27use strict; use warnings;
28use local::lib '$dir1';
4a1c5f7f 29warn 'using lib dir $dir1', "\\n";
1e1de821 30if (grep { m{^\\Q$dir1\\E/} } \@INC) {
24351831 31 exit 0;
32}
4a1c5f7f 33warn '\@INC is: ', join("\\n", \@INC), "\\n";
24351831 34exit 1
35EOM
36close $fh;
37
38my $exit_val = system($^X, '-Ilib', '-T', $filename);
39
40is($exit_val >> 8, 0, 'test script exited with 0, local::lib dir found in @INC');