Commit | Line | Data |
a635c943 |
1 | #!./perl -Tw |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
7 | |
8 | use strict; |
91fded41 |
9 | use File::Spec; |
e69a2255 |
10 | my($blib, $blib_arch, $blib_lib, @blib_dirs); |
a635c943 |
11 | |
12 | sub _cleanup { |
e69a2255 |
13 | rmdir foreach reverse (@_); |
14 | unlink "stderr" unless $^O eq 'MacOS'; |
a635c943 |
15 | } |
16 | |
17 | sub _mkdirs { |
18 | for my $dir (@_) { |
19 | next if -d $dir; |
20 | mkdir $dir or die "Can't mkdir $dir: $!" if ! -d $dir; |
21 | } |
22 | } |
23 | |
24 | |
e69a2255 |
25 | BEGIN { |
26 | if ($^O eq 'MacOS') |
27 | { |
16398b42 |
28 | $MacPerl::Architecture = $MacPerl::Architecture; # shhhhh |
e69a2255 |
29 | $blib = ":blib:"; |
30 | $blib_lib = ":blib:lib:"; |
31 | $blib_arch = ":blib:lib:$MacPerl::Architecture:"; |
32 | @blib_dirs = ($blib, $blib_lib, $blib_arch); # order |
33 | } |
34 | else |
35 | { |
36 | $blib = "blib"; |
37 | $blib_arch = "blib/arch"; |
38 | $blib_lib = "blib/lib"; |
39 | @blib_dirs = ($blib, $blib_arch, $blib_lib); |
40 | } |
41 | _cleanup( @blib_dirs ); |
42 | } |
a635c943 |
43 | |
44 | use Test::More tests => 7; |
45 | |
46 | eval 'use blib;'; |
47 | ok( $@ =~ /Cannot find blib/, 'Fails if blib directory not found' ); |
48 | |
e69a2255 |
49 | _mkdirs( @blib_dirs ); |
a635c943 |
50 | |
51 | { |
4940c443 |
52 | my $warnings = ''; |
a635c943 |
53 | local $SIG{__WARN__} = sub { $warnings = join '', @_ }; |
54 | use_ok('blib'); |
91fded41 |
55 | is( $warnings, '', 'use blib is nice and quiet' ); |
a635c943 |
56 | } |
57 | |
58 | is( @INC, 3, '@INC now has 3 elements' ); |
59 | is( $INC[2], '../lib', 'blib added to the front of @INC' ); |
60 | |
bea1ee5e |
61 | if ($^O eq 'VMS') { |
62 | # Unix syntax is accepted going in but it's not what comes out |
91fded41 |
63 | # So we don't use catdir above |
bea1ee5e |
64 | $blib_arch = 'blib.arch]'; |
65 | $blib_lib = 'blib.lib]'; |
66 | } |
91fded41 |
67 | elsif ($^O ne 'MacOS') |
68 | { |
69 | $blib_arch = File::Spec->catdir("blib","arch"); |
70 | $blib_lib = File::Spec->catdir("blib","lib"); |
71 | } |
72 | |
73 | |
74 | ok( grep(m|\Q$blib_lib\E$|, @INC[0,1]) == 1, " $blib_lib in \@INC"); |
75 | ok( grep(m|\Q$blib_arch\E$|, @INC[0,1]) == 1, " $blib_arch in \@INC"); |
a635c943 |
76 | |
e69a2255 |
77 | END { _cleanup( @blib_dirs ); } |