From: Michael G. Schwern Date: Sat, 8 Sep 2001 19:45:46 +0000 (-0400) Subject: [REPATCH] Re: [PATCH] new test lib/blib.t X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a635c9437ef25a8c106276588579a3871545a5ac;p=p5sagit%2Fp5-mst-13.2.git [REPATCH] Re: [PATCH] new test lib/blib.t Message-ID: <20010908194546.C9193@blackrider> p4raw-id: //depot/perl@11953 --- diff --git a/MANIFEST b/MANIFEST index f0fc9b0..3004189 100644 --- a/MANIFEST +++ b/MANIFEST @@ -763,6 +763,7 @@ lib/bigint.pl An arbitrary precision integer arithmetic package lib/bigint.t See if bigint.pl works lib/bigrat.pl An arbitrary precision rational arithmetic package lib/blib.pm For "use blib" +lib/blib.t blib.pm test lib/bytes.pm Pragma to enable byte operations lib/bytes_heavy.pl Support routines for byte pragma lib/cacheout.pl Manages output filehandles when you need too many diff --git a/lib/blib.pm b/lib/blib.pm index 0916f79..aaecd45 100644 --- a/lib/blib.pm +++ b/lib/blib.pm @@ -38,8 +38,9 @@ Nick Ing-Simmons nik@tiuk.ti.com use Cwd; -use vars qw($VERSION); +use vars qw($VERSION $Verbose); $VERSION = '1.00'; +$Verbose = 0; sub import { @@ -61,7 +62,7 @@ sub import if (-d $blib && -d "$blib/arch" && -d "$blib/lib") { unshift(@INC,"$blib/arch","$blib/lib"); - warn "Using $blib\n"; + warn "Using $blib\n" if $Verbose; return; } $dir .= "/.."; diff --git a/lib/blib.t b/lib/blib.t new file mode 100644 index 0000000..4e0d3ea --- /dev/null +++ b/lib/blib.t @@ -0,0 +1,45 @@ +#!./perl -Tw + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +use strict; + +sub _cleanup { + rmdir foreach reverse qw(blib blib/arch blib/lib); + unlink "stderr"; +} + +sub _mkdirs { + for my $dir (@_) { + next if -d $dir; + mkdir $dir or die "Can't mkdir $dir: $!" if ! -d $dir; + } +} + + +BEGIN { _cleanup } + +use Test::More tests => 7; + +eval 'use blib;'; +ok( $@ =~ /Cannot find blib/, 'Fails if blib directory not found' ); + +_mkdirs(qw(blib blib/arch blib/lib)); + +{ + my $warnings; + local $SIG{__WARN__} = sub { $warnings = join '', @_ }; + use_ok('blib'); + is( $warnings, '', 'use blib is niiiice and quiet' ); +} + +is( @INC, 3, '@INC now has 3 elements' ); +is( $INC[2], '../lib', 'blib added to the front of @INC' ); + +ok( grep(m|blib/lib$|, @INC[0,1]) == 1, ' blib/lib in @INC'); +ok( grep(m|blib/arch$|, @INC[0,1]) == 1, ' blib/arch in @INC'); + +END { _cleanup(); } diff --git a/t/lib/1_compile.t b/t/lib/1_compile.t index a7871fc..368d4f6 100644 --- a/t/lib/1_compile.t +++ b/t/lib/1_compile.t @@ -194,6 +194,7 @@ Time::tm UNIVERSAL attributes base +blib bytes ops warnings::register