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