This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Just sorting to guarantee order is not enough.
[perl5.git] / lib / blib.t
CommitLineData
a635c943
MS
1#!./perl -Tw
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
8use strict;
9
10sub _cleanup {
11 rmdir foreach reverse qw(blib blib/arch blib/lib);
12 unlink "stderr";
13}
14
15sub _mkdirs {
16 for my $dir (@_) {
17 next if -d $dir;
18 mkdir $dir or die "Can't mkdir $dir: $!" if ! -d $dir;
19 }
20}
21
22
23BEGIN { _cleanup }
24
25use Test::More tests => 7;
26
27eval 'use blib;';
28ok( $@ =~ /Cannot find blib/, 'Fails if blib directory not found' );
29
30_mkdirs(qw(blib blib/arch blib/lib));
31
32{
33 my $warnings;
34 local $SIG{__WARN__} = sub { $warnings = join '', @_ };
35 use_ok('blib');
36 is( $warnings, '', 'use blib is niiiice and quiet' );
37}
38
39is( @INC, 3, '@INC now has 3 elements' );
40is( $INC[2], '../lib', 'blib added to the front of @INC' );
41
42ok( grep(m|blib/lib$|, @INC[0,1]) == 1, ' blib/lib in @INC');
43ok( grep(m|blib/arch$|, @INC[0,1]) == 1, ' blib/arch in @INC');
44
45END { _cleanup(); }