From: Michael G. Schwern Date: Sun, 16 Jun 2002 03:49:27 +0000 (-0400) Subject: Subject: [PATCH] Sync MakeMaker 6.01 -> 6.02 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d5d4ec93a4679c6ba299b53290a0903a25094cec;p=p5sagit%2Fp5-mst-13.2.git Subject: [PATCH] Sync MakeMaker 6.01 -> 6.02 Date: Sun, 16 Jun 2002 03:49:27 -0400 Message-Id: <20020616074927.GD7403@ool-18b93024.dyn.optonline.net> Subject: [PATCH] Test::Harness 2.24 -> 2.25 From: Michael G Schwern Date: Sun, 16 Jun 2002 03:58:40 -0400 Message-Id: <20020616075840.GE7403@ool-18b93024.dyn.optonline.net> p4raw-id: //depot/perl@17256 --- diff --git a/lib/ExtUtils/Changes b/lib/ExtUtils/Changes index 5f274c9..268065a 100644 --- a/lib/ExtUtils/Changes +++ b/lib/ExtUtils/Changes @@ -1,3 +1,14 @@ +6.02 Sat Jun 15 19:46:06 EDT 2002 + - ExtUtils::Installed->modules() was broken in scalar context + - Sync bleadperl 16922: Netware updates from Ananth Kesari. + - Sync bleadperl 16922: MM_NW5 tests + - Sync bleadperl 16938 & 16974: MM_MacOS->macify fixes from pudge. + - Sync bleadperl 16989 & 16942: Small test fixes for MacPerl from pudge. + - Improved WriteMakefile param verification to differenciate between + parameters which don't exist and those that just take strings/numbers. + [RT #707] + * Documented TEST_VERBOSE + 6.01 Thu May 30 14:48:57 EDT 2002 - MacOS Classic fixes from Pudge: recursive make repair, post_initialize() now used, DEFINE & INC work with relative paths, diff --git a/lib/ExtUtils/Command.pm b/lib/ExtUtils/Command.pm index 22eece7..6593ab3 100644 --- a/lib/ExtUtils/Command.pm +++ b/lib/ExtUtils/Command.pm @@ -106,9 +106,9 @@ sub rm_f expand_wildcards(); foreach (@ARGV) { - next unless -f $_; + next unless -f $_; next if unlink($_); - chmod(0777,$_); + chmod(0777,$_); next if unlink($_); carp "Cannot delete $_:$!"; } @@ -147,7 +147,7 @@ sub mv croak("Too many arguments") if (@ARGV > 1 && ! -d $dst); while (@ARGV) { - my $src = shift(@ARGV); + my $src = shift(@ARGV); move($src,$dst); } } @@ -157,7 +157,7 @@ sub mv Copies source to destination. Multiple sources are allowed if destination is an existing directory. -=cut +=cut sub cp { @@ -166,7 +166,7 @@ sub cp croak("Too many arguments") if (@ARGV > 1 && ! -d $dst); while (@ARGV) { - my $src = shift(@ARGV); + my $src = shift(@ARGV); copy($src,$dst); } } diff --git a/lib/ExtUtils/Installed.pm b/lib/ExtUtils/Installed.pm index 7edde47..1375a82 100644 --- a/lib/ExtUtils/Installed.pm +++ b/lib/ExtUtils/Installed.pm @@ -12,7 +12,7 @@ use File::Spec; require VMS::Filespec if $^O eq 'VMS'; use vars qw($VERSION); -$VERSION = '0.05'; +$VERSION = '0.06'; my $DOSISH = ($^O =~ /^(MSWin\d\d|os2|dos|mint)$/); @@ -130,7 +130,9 @@ sub new { sub modules { my ($self) = @_; - return sort keys %$self; + + # Bug/feature of sort in scalar context requires this. + return wantarray ? sort keys %$self : keys %$self; } sub files { diff --git a/lib/ExtUtils/MM_MacOS.pm b/lib/ExtUtils/MM_MacOS.pm index 71eb969..cbef99b 100644 --- a/lib/ExtUtils/MM_MacOS.pm +++ b/lib/ExtUtils/MM_MacOS.pm @@ -50,7 +50,7 @@ sub new { } mkdir("Obj", 0777) unless -d "Obj"; - + $self = {} unless (defined $self); my(%initial_att) = %$self; # record initial attributes diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index cb516a5..0cd45eb 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -19,7 +19,7 @@ use vars qw($VERSION @ISA use ExtUtils::MakeMaker qw($Verbose neatvalue); -$VERSION = '1.32'; +$VERSION = '1.33'; require ExtUtils::MM_Any; @ISA = qw(ExtUtils::MM_Any); @@ -1719,10 +1719,13 @@ usually solves this kind of problem. } # strip blanks - if ($self->{VERSION}) { + if (defined $self->{VERSION}) { $self->{VERSION} =~ s/^\s+//; $self->{VERSION} =~ s/\s+$//; } + else { + $self->{VERSION} = ''; + } ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g; $self->{DISTVNAME} = "$self->{DISTNAME}-$self->{VERSION}"; @@ -2741,7 +2744,7 @@ q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "], $self->{MAKEFILE}, q[";' \\ -e 'print "Manifying $$m{$$_}\n";' \\ -e 'system(q[$(PERLRUN) $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\ --e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}' +-e 'chmod(oct($(PERM_RW)), $$m{$$_}) or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}' ]; push @m, "\nmanifypods : pure_all "; push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}; diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm index 69cf106..91cc91c 100644 --- a/lib/ExtUtils/MakeMaker.pm +++ b/lib/ExtUtils/MakeMaker.pm @@ -2,10 +2,10 @@ package ExtUtils::MakeMaker; BEGIN {require 5.005_03;} -$VERSION = "6.01"; +$VERSION = "6.02"; $Version_OK = "5.49"; # Makefiles older than $Version_OK will die # (Will be checked from MakeMaker version 4.13 onwards) -($Revision = substr(q$Revision: 1.59 $, 10)) =~ s/\s+$//; +($Revision = substr(q$Revision: 1.61 $, 10)) =~ s/\s+$//; require Exporter; use Config; @@ -54,32 +54,111 @@ sub WriteMakefile { } -# Basic signatures of the attributes WriteMakefile takes. Each is -# the reference type. Any not noted simply take strings. +# Basic signatures of the attributes WriteMakefile takes. Each is the +# reference type. Empty value indicate it takes a non-reference +# scalar. my %Att_Sigs = ( - C => 'array', - CONFIG => 'array', - CONFIGURE => 'code', - DIR => 'array', - DL_FUNCS => 'hash', - DL_VARS => 'array', - EXCLUDE_EXT=> 'array', - EXE_FILES => 'array', - FUNCLIST => 'array', - H => 'array', - IMPORTS => 'hash', - INCLUDE_EXT=> 'array', - LIBS => ['array','string'], - MAN1PODS => 'hash', - MAN3PODS => 'hash', - PL_FILES => 'hash', - PM => 'hash', - PMLIBDIRS => 'array', - PREREQ_PM => 'hash', - SKIP => 'array', - TYPEMAPS => 'array', - XS => 'hash', + ABSTRACT => '', + ABSTRACT_FROM => '', + AUTHOR => '', + BINARY_LOCATION => '', + C => 'array', + CCFLAGS => '', + CONFIG => 'array', + CONFIGURE => 'code', + DEFINE => '', + DIR => 'array', + DISTNAME => '', + DL_FUNCS => 'hash', + DL_VARS => 'array', + EXCLUDE_EXT => 'array', + EXE_FILES => 'array', + FIRST_MAKEFILE => '', + FULLPERL => '', + FULLPERLRUN => '', + FULLPERLRUNINST => '', + FUNCLIST => 'array', + H => 'array', + IMPORTS => 'hash', + INC => '', + INCLUDE_EXT => 'array', + INSTALLARCHLIB => '', + INSTALLBIN => '', + INSTALLDIRS => '', + INSTALLMAN1DIR => '', + INSTALLMAN3DIR => '', + INSTALLPRIVLIB => '', + INSTALLSCRIPT => '', + INSTALLSITEARCH => '', + INSTALLSITEBIN => '', + INSTALLSITELIB => '', + INSTALLSITEMAN1DIR => '', + INSTALLSITEMAN3DIR => '', + INSTALLVENDORARCH => '', + INSTALLVENDORBIN => '', + INSTALLVENDORLIB => '', + INSTALLVENDORMAN1DIR => '', + INSTALLVENDORMAN3DIR => '', + INST_ARCHLIB => '', + INST_BIN => '', + INST_LIB => '', + INST_MAN1DIR => '', + INST_MAN3DIR => '', + INST_SCRIPT => '', + _KEEP_AFTER_FLUSH => '', + LDFROM => '', + LIB => '', + LIBPERL_A => '', + LIBS => ['array',''], + LINKTYPE => '', + MAKEAPERL => '', + MAKEFILE => '', + MAN1PODS => 'hash', + MAN3PODS => 'hash', + MAP_TARGET => '', + MYEXTLIB => '', + NAME => '', + NEEDS_LINKING => '', + NOECHO => '', + NORECURS => '', + NO_VC => '', + OBJECT => '', + OPTIMIZE => '', + PERL => '', + PERL_CORE => '', + PERLMAINCC => '', + PERL_ARCHLIB => '', + PERL_LIB => '', + PERL_MALLOC_OK => '', + PERLRUN => '', + PERLRUNINST => '', + PERL_SRC => '', + PERM_RW => '', + PERM_RWX => '', + PL_FILES => 'hash', + PM => 'hash', + PMLIBDIRS => 'array', + PM_FILTER => '', + POLLUTE => '', + PPM_INSTALL_EXEC => '', + PPM_INSTALL_SCRIPT => '', + PREFIX => '', + PREREQ_FATAL => '', + PREREQ_PM => 'hash', + PREREQ_PRINT => '', + PRINT_PREREQ => '', + SITEPREFIX => '', + SKIP => 'array', + TYPEMAPS => 'array', + VENDORPREFIX => '', + VERBINST => '', + VERSION => '', + VERSION_FROM => '', + XS => 'hash', + XSOPT => '', + XSPROTOARG => '', + XS_VERSION => '', clean => 'hash', depend => 'hash', @@ -93,10 +172,10 @@ my %Att_Sigs = ); my %Default_Att = ( - string => '', + '' => '', hash => {}, array => [], - code => sub {} + code => sub {}, ); sub _verify_att { @@ -104,14 +183,19 @@ sub _verify_att { while( my($key, $val) = each %$att ) { my $sig = $Att_Sigs{$key}; - my @sigs = ref $sig ? @$sig : ($sig || 'string'); - my $given = lc ref $val || 'string'; + unless( defined $sig ) { + warn "WARNING: $key is not a known parameter.\n"; + next; + } + + my @sigs = ref $sig ? @$sig : $sig; + my $given = lc ref $val; unless( grep $given eq $_, @sigs ) { - my $takes = join " or ", map { $_ ne 'string' ? "$_ reference" - : "string/number" + my $takes = join " or ", map { $_ ne '' ? "$_ reference" + : "string/number" } @sigs; - my $has = $given ne 'string' ? "$given reference" - : "string/number"; + my $has = $given ne '' ? "$given reference" + : "string/number"; warn "WARNING: $key takes a $takes not a $has.\n". " Please inform the author.\n"; $att->{$key} = $Default_Att{$sigs[0]}; @@ -954,14 +1038,17 @@ Other interesting targets in the generated Makefile are =head2 make test MakeMaker checks for the existence of a file named F in the -current directory and if it exists it adds commands to the test target -of the generated Makefile that will execute the script with the proper -set of perl C<-I> options. +current directory and if it exists it execute the script with the +proper set of perl C<-I> options. MakeMaker also checks for any files matching glob("t/*.t"). It will -add commands to the test target of the generated Makefile that execute -all matching files in alphabetical order via the L -module with the C<-I> switches set correctly. +execute all matching files in alphabetical order via the +L module with the C<-I> switches set correctly. + +If you'd like to see the raw output of your tests, set the +C variable to true. + + make test TEST_VERBOSE=1 =head2 make testdb @@ -969,13 +1056,13 @@ A useful variation of the above is the target C. It runs the test under the Perl debugger (see L). If the file F exists in the current directory, it is used for the test. -If you want to debug some other testfile, set C variable +If you want to debug some other testfile, set the C variable thusly: make testdb TEST_FILE=t/mytest.t By default the debugger is called using C<-d> option to perl. If you -want to specify some other option, set C variable: +want to specify some other option, set the C variable: make testdb TESTDB_SW=-Dx @@ -1795,13 +1882,6 @@ by the PREFIX. Defaults to $Config{installprefixexp}. -=item PREREQ_PM - -Hashref: Names of modules that need to be available to run this -extension (e.g. Fcntl for SDBM_File) are the keys of the hash and the -desired version is the value. If the required version number is 0, we -only check if any version is installed already. - =item PREREQ_FATAL Bool. If this parameter is true, failing to have the required modules @@ -1816,6 +1896,13 @@ at a later time, e.g. after an unsuccessful B of your module. It is I rare to have to use C at all! +=item PREREQ_PM + +Hashref: Names of modules that need to be available to run this +extension (e.g. Fcntl for SDBM_File) are the keys of the hash and the +desired version is the value. If the required version number is 0, we +only check if any version is installed already. + =item PREREQ_PRINT Bool. If this parameter is true, the prerequisites will be printed to @@ -1888,7 +1975,7 @@ MakeMaker object. The following lines will be parsed o.k.: $VERSION = '1.00'; *VERSION = \'1.01'; - ( $VERSION ) = '$Revision: 1.59 $ ' =~ /\$Revision:\s+([^\s]+)/; + ( $VERSION ) = '$Revision: 1.61 $ ' =~ /\$Revision:\s+([^\s]+)/; $FOO::VERSION = '1.10'; *FOO::VERSION = \'1.11'; our $VERSION = 1.2.3; # new for perl5.6.0 diff --git a/lib/ExtUtils/t/00setup_dummy.t b/lib/ExtUtils/t/00setup_dummy.t index a55fc00..2d5b1ee 100644 --- a/lib/ExtUtils/t/00setup_dummy.t +++ b/lib/ExtUtils/t/00setup_dummy.t @@ -12,12 +12,12 @@ chdir 't'; use strict; use Test::More tests => 9; -use File::Spec::Functions; -use File::Path; use File::Basename; +use File::Path; +use File::Spec; my %Files = ( - catfile(curdir(),'Big-Dummy','lib','Big','Dummy.pm') => <<'END', + 'Big-Dummy/lib/Big/Dummy.pm' => <<'END', package Big::Dummy; $VERSION = 0.01; @@ -25,7 +25,7 @@ $VERSION = 0.01; 1; END - catfile(curdir(),'Big-Dummy','Makefile.PL') => <<'END', + 'Big-Dummy/Makefile.PL' => <<'END', use ExtUtils::MakeMaker; printf "Current package is: %s\n", __PACKAGE__; @@ -37,14 +37,14 @@ WriteMakefile( ); END - catfile(curdir(),'Big-Dummy','t','compile.t') => <<'END', + 'Big-Dummy/t/compile.t' => <<'END', print "1..2\n"; print eval "use Big::Dummy; 1;" ? "ok 1\n" : "not ok 1\n"; print "ok 2 - TEST_VERBOSE\n"; END - catfile(curdir(),'Big-Dummy','Liar','t','sanity.t') => <<'END', + 'Big-Dummy/Liar/t/sanity.t' => <<'END', print "1..3\n"; print eval "use Big::Dummy; 1;" ? "ok 1\n" : "not ok 1\n"; @@ -52,7 +52,7 @@ print eval "use Big::Liar; 1;" ? "ok 2\n" : "not ok 2\n"; print "ok 3 - TEST_VERBOSE\n"; END - catfile(curdir(),'Big-Dummy','Liar','lib','Big','Liar.pm') => <<'END', + 'Big-Dummy/Liar/lib/Big/Liar.pm' => <<'END', package Big::Liar; $VERSION = 0.01; @@ -60,7 +60,7 @@ $VERSION = 0.01; 1; END - catfile(curdir(),'Big-Dummy','Liar','Makefile.PL') => <<'END', + 'Big-Dummy/Liar/Makefile.PL' => <<'END', use ExtUtils::MakeMaker; my $mm = WriteMakefile( @@ -75,7 +75,7 @@ foreach my $key (qw(INST_LIB INST_ARCHLIB)) { } END - catfile(curdir(),'Problem-Module','Makefile.PL') => <<'END', + 'Problem-Module/Makefile.PL' => <<'END', use ExtUtils::MakeMaker; WriteMakefile( @@ -83,7 +83,7 @@ WriteMakefile( ); END - catfile(curdir(),'Problem-Module','subdir','Makefile.PL') => <<'END', + 'Problem-Module/subdir/Makefile.PL' => <<'END', printf "\@INC %s .\n", (grep { $_ eq '.' } @INC) ? "has" : "doesn't have"; warn "I think I'm going to be sick\n"; @@ -93,6 +93,9 @@ END ); while(my($file, $text) = each %Files) { + # Convert to a relative, native file path. + $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file); + my $dir = dirname($file); mkpath $dir; open(FILE, ">$file"); diff --git a/lib/ExtUtils/t/Command.t b/lib/ExtUtils/t/Command.t index 2e0e08f..ff9eec1 100644 --- a/lib/ExtUtils/t/Command.t +++ b/lib/ExtUtils/t/Command.t @@ -107,7 +107,8 @@ BEGIN { SKIP: { if ($^O eq 'amigaos' || $^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'dos' || $^O eq 'cygwin' || - $^O eq 'MacOS') { + $^O eq 'MacOS' + ) { skip( "different file permission semantics on $^O", 3); } diff --git a/lib/ExtUtils/t/Installed.t b/lib/ExtUtils/t/Installed.t index a1db434..d62afba 100644 --- a/lib/ExtUtils/t/Installed.t +++ b/lib/ExtUtils/t/Installed.t @@ -20,7 +20,7 @@ use File::Path; use File::Basename; use File::Spec; -use Test::More tests => 45; +use Test::More tests => 46; BEGIN { use_ok( 'ExtUtils::Installed' ) } @@ -81,7 +81,9 @@ ok( $ei->_is_under('baz', @under), '... should find file under dir' ); my $wrotelist; -ok(scalar mkpath('auto/FakeMod')); + +rmtree 'auto/FakeMod'; +ok( mkpath('auto/FakeMod') ); END { rmtree 'auto/FakeMod' } ok(open(PACKLIST, '>auto/FakeMod/.packlist')); @@ -129,6 +131,9 @@ $ei->{$_} = 1 for qw( abc def ghi ); is( join(' ', $ei->modules()), 'abc def ghi', 'modules() should return sorted keys' ); +# This didn't work for a long time due to a sort in scalar context oddity. +is( $ei->modules, 3, 'modules() in scalar context' ); + # files $ei->{goodmod} = { packlist => { diff --git a/lib/ExtUtils/t/writemakefile_args.t b/lib/ExtUtils/t/writemakefile_args.t index 3877aa6..2160f08 100644 --- a/lib/ExtUtils/t/writemakefile_args.t +++ b/lib/ExtUtils/t/writemakefile_args.t @@ -14,7 +14,7 @@ BEGIN { } use strict; -use Test::More tests => 12; +use Test::More tests => 16; use TieOut; use MakeMaker::Test::Utils; @@ -53,7 +53,7 @@ VERIFY VERSION_FROM => 'lib/Big/Dummy.pm', AUTHOR => sub {}, ); - + is( $warnings, < 'lib/Big/Dummy.pm', LIBS => '-lwibble -lwobble', ); - + # We'll get warnings about the bogus libs, that's ok. unlike( $warnings, qr/WARNING: .* takes/ ); is_deeply( $mm->{LIBS}, ['-lwibble -lwobble'] ); @@ -81,7 +81,7 @@ VERIFY VERSION_FROM => 'lib/Big/Dummy.pm', LIBS => ['-lwibble', '-lwobble'], ); - + # We'll get warnings about the bogus libs, that's ok. unlike( $warnings, qr/WARNING: .* takes/ ); is_deeply( $mm->{LIBS}, ['-lwibble', '-lwobble'] ); @@ -92,9 +92,22 @@ VERIFY VERSION_FROM => 'lib/Big/Dummy.pm', LIBS => { wibble => "wobble" }, ); - + # We'll get warnings about the bogus libs, that's ok. like( $warnings, qr{^WARNING: LIBS takes a array reference or string/number not a hash reference}m ); is_deeply( $mm->{LIBS}, [] ); + + $warnings = ''; + $mm = WriteMakefile( + NAME => 'Big::Dummy', + WIBBLE => 'something', + wump => { foo => 42 }, + ); + + like( $warnings, qr{^WARNING: WIBBLE is not a known parameter.\n}m ); + like( $warnings, qr{^WARNING: wump is not a known parameter.\n}m ); + + is( $mm->{WIBBLE}, 'something' ); + is_deeply( $mm->{wump}, { foo => 42 } ); } diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm index 4714f77..d79a6cb 100644 --- a/lib/Test/Harness.pm +++ b/lib/Test/Harness.pm @@ -1,5 +1,5 @@ # -*- Mode: cperl; cperl-indent-level: 4 -*- -# $Id: Harness.pm,v 1.33 2002/05/29 23:02:48 schwern Exp $ +# $Id: Harness.pm,v 1.37 2002/06/16 06:55:09 schwern Exp $ package Test::Harness; @@ -12,7 +12,7 @@ use Config; use strict; use vars qw($VERSION $Verbose $Switches $Have_Devel_Corestack $Curtest - $Columns $verbose $switches $ML + $Columns $verbose $switches $ML $Strap @ISA @EXPORT @EXPORT_OK ); @@ -22,7 +22,7 @@ use vars qw($VERSION $Verbose $Switches $Have_Devel_Corestack $Curtest $Have_Devel_Corestack = 0; -$VERSION = '2.24'; +$VERSION = '2.25'; $ENV{HARNESS_ACTIVE} = 1; @@ -36,7 +36,7 @@ my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE}; my $Files_In_Dir = $ENV{HARNESS_FILELEAK_IN_DIR}; -my $Strap = Test::Harness::Straps->new; +$Strap = Test::Harness::Straps->new; @ISA = ('Exporter'); @EXPORT = qw(&runtests); @@ -324,7 +324,8 @@ or failed based on their output to STDOUT (details above). It prints out each individual test which failed along with a summary report and a how long it all took. -It returns true if everything was ok, false otherwise. +It returns true if everything was ok. Otherwise it will die() with +one of the messages in the DIAGNOSTICS section. =for _private This is just _run_all_tests() plus _show_results() @@ -496,7 +497,7 @@ sub _run_all_tests { print "$test{ml}ok\n ".join(', ', @msg)."\n"; } elsif ($test{max}) { print "$test{ml}ok\n"; - } elsif (length $test{skip_all}) { + } elsif (defined $test{skip_all} and length $test{skip_all}) { print "skipped\n all skipped: $test{skip_all}\n"; $tot{skipped}++; } else { diff --git a/lib/Test/Harness/Changes b/lib/Test/Harness/Changes index 03eaab3..53862ff 100644 --- a/lib/Test/Harness/Changes +++ b/lib/Test/Harness/Changes @@ -1,5 +1,17 @@ Revision history for Perl extension Test::Harness +2.25 Sun Jun 16 03:00:33 EDT 2002 + - $Strap is now a global to allow Test::Harness::Straps + experimentation. + - Little spelling nit in a diagnostic. + - Chris Richmond noted that the runtests() docs were wrong. It will + die, not return false, when any tests fail. This is silly, but + historically necessary for 'make test'. Docs corrected. + - MacPerl test fixes from Pudge. (mutation of bleadperl@16989) + - Undef warning introduced in 2.24 on skipped tests with no reasons + fixed. + * Test::Harness now depends on File::Spec + 2.24 Wed May 29 19:02:18 EDT 2002 * Nikola Knezevic found a bug when tests are completely skipped but no reason is given it was considered a failure. diff --git a/lib/Test/Harness/Straps.pm b/lib/Test/Harness/Straps.pm index 7b018ae..8f3d116 100644 --- a/lib/Test/Harness/Straps.pm +++ b/lib/Test/Harness/Straps.pm @@ -1,12 +1,12 @@ # -*- Mode: cperl; cperl-indent-level: 4 -*- -# $Id: Straps.pm,v 1.8 2002/05/29 23:02:48 schwern Exp $ +# $Id: Straps.pm,v 1.11 2002/06/16 06:55:10 schwern Exp $ package Test::Harness::Straps; use strict; use vars qw($VERSION); use Config; -$VERSION = '0.12'; +$VERSION = '0.13'; use Test::Harness::Assert; use Test::Harness::Iterator; @@ -187,7 +187,7 @@ sub _analyze_line { # print "ok $num\n"; if( $self->{saw_lone_not} && ($self->{lone_not_line} == $self->{line} - 1) ) - { + { $result{ok} = 0; } @@ -207,7 +207,7 @@ sub _analyze_line { $totals->{ok}++ if $pass; if( $result{number} > 100000 ) { - warn "Enourmous test number seen [test $result{number}]\n"; + warn "Enormous test number seen [test $result{number}]\n"; warn "Can't detailize, too big.\n"; } else { @@ -328,11 +328,8 @@ sub _switches { # When taint mode is on, PERL5LIB is ignored. So we need to put # all that on the command line as -Is. - if ($first =~ /^#!.*\bperl.*\s-\w*([Tt]+)/) { - $s .= join " ", qq[ "-$1"], map {qq["-I$_"]} $self->_filtered_INC; - } elsif ($^O eq 'MacOS') { - $s .= join " ", map {qq["-I$_"]} $self->_filtered_INC; - } + $s .= join " ", qq[ "-$1"], map {qq["-I$_"]} $self->_filtered_INC + if $first =~ /^#!.*\bperl.*\s-\w*([Tt]+)/; close(TEST) or print "can't close $file. $!\n"; @@ -355,7 +352,7 @@ sub _INC2PERL5LIB { $self->{_old5lib} = $ENV{PERL5LIB}; return join $Config{path_sep}, $self->_filtered_INC; -} +} =item B<_filtered_INC> @@ -399,7 +396,7 @@ sub _restore_PERL5LIB { $ENV{PERL5LIB} = $self->{_old5lib}; } } - + =end _private diff --git a/lib/Test/Harness/t/callback.t b/lib/Test/Harness/t/callback.t index 74b2fe9..d774958 100644 --- a/lib/Test/Harness/t/callback.t +++ b/lib/Test/Harness/t/callback.t @@ -10,13 +10,13 @@ BEGIN { } } -use File::Spec::Functions; +use Test::More; +use File::Spec; +my $Curdir = File::Spec->curdir; my $SAMPLE_TESTS = $ENV{PERL_CORE} - ? catdir(curdir(), 'lib', 'sample-tests') - : catdir(curdir(), 't', 'sample-tests'); - -use Test::More; + ? File::Spec->catdir($Curdir, 'lib', 'sample-tests') + : File::Spec->catdir($Curdir, 't', 'sample-tests'); %samples = ( bailout => [qw( header test test test bailout )], @@ -51,15 +51,10 @@ $strap->{callback} = sub { my($self, $line, $type, $totals) = @_; push @out, $type; }; - -$SAMPLE_TESTS = VMS::Filespec::unixify($SAMPLE_TESTS) if $^O eq 'VMS'; while( my($test, $expect) = each %samples ) { local @out = (); - - $strap->analyze_file($^O eq 'MacOS' ? - catfile($SAMPLE_TESTS, $test) : - "$SAMPLE_TESTS/$test"); + $strap->analyze_file(File::Spec->catfile($SAMPLE_TESTS, $test)); is_deeply(\@out, $expect, "$test callback"); } diff --git a/lib/Test/Harness/t/strap-analyze.t b/lib/Test/Harness/t/strap-analyze.t index c3e3d1e..06c0966 100644 --- a/lib/Test/Harness/t/strap-analyze.t +++ b/lib/Test/Harness/t/strap-analyze.t @@ -10,20 +10,18 @@ BEGIN { } } -use File::Spec::Functions; - -my $SAMPLE_TESTS = $ENV{PERL_CORE} - ? catdir(curdir(), 'lib', 'sample-tests') - : catdir(curdir(), 't', 'sample-tests'); - use strict; use Test::More; +use File::Spec; + +my $Curdir = File::Spec->curdir; +my $SAMPLE_TESTS = $ENV{PERL_CORE} + ? File::Spec->catdir($Curdir, 'lib', 'sample-tests') + : File::Spec->catdir($Curdir, 't', 'sample-tests'); -if ($^O eq 'MacOS') { - plan skip_all => "Exit status broken on Mac OS"; -} -my $IsVMS = $^O eq 'VMS'; +my $IsMacPerl = $^O eq 'MacOS'; +my $IsVMS = $^O eq 'VMS'; # VMS uses native, not POSIX, exit codes. my $die_exit = $IsVMS ? 44 : 1; @@ -444,17 +442,14 @@ my %samples = ( }, ); -plan tests => (keys(%samples) * 3) + 3; +plan tests => (keys(%samples) * 4) + 3; use_ok('Test::Harness::Straps'); $SIG{__WARN__} = sub { - warn @_ unless $_[0] =~ /^Enourmous test number/ || + warn @_ unless $_[0] =~ /^Enormous test number/ || $_[0] =~ /^Can't detailize/ }; - -$SAMPLE_TESTS = VMS::Filespec::unixify($SAMPLE_TESTS) if $^O eq 'VMS'; - while( my($test, $expect) = each %samples ) { for (0..$#{$expect->{details}}) { $expect->{details}[$_]{type} = '' @@ -465,20 +460,29 @@ while( my($test, $expect) = each %samples ) { unless exists $expect->{details}[$_]{reason}; } + my $test_path = File::Spec->catfile($SAMPLE_TESTS, $test); my $strap = Test::Harness::Straps->new; - my %results = $strap->analyze_file($^O eq 'MacOS' ? - catfile($SAMPLE_TESTS, $test) : - "$SAMPLE_TESTS/$test"); + my %results = $strap->analyze_file($test_path); is_deeply($results{details}, $expect->{details}, "$test details" ); delete $expect->{details}; delete $results{details}; - # We can only check if it's zero or non-zero. - is( !!$results{'wait'}, !!$expect->{'wait'}, 'wait status' ); - delete $results{'wait'}; - delete $expect->{'wait'}; + SKIP: { + skip '$? unreliable in MacPerl', 2 if $IsMacPerl; + + # We can only check if it's zero or non-zero. + is( !!$results{'wait'}, !!$expect->{'wait'}, 'wait status' ); + delete $results{'wait'}; + delete $expect->{'wait'}; + + # Have to check the exit status seperately so we can skip it + # in MacPerl. + is( $results{'exit'}, $expect->{'exit'} ); + delete $results{'exit'}; + delete $expect->{'exit'}; + } is_deeply(\%results, $expect, " the rest $test" ); } diff --git a/lib/Test/Harness/t/test-harness.t b/lib/Test/Harness/t/test-harness.t index 1e9f58d..c04e2e2 100644 --- a/lib/Test/Harness/t/test-harness.t +++ b/lib/Test/Harness/t/test-harness.t @@ -10,13 +10,14 @@ BEGIN { } } -use File::Spec::Functions; +use strict; +use File::Spec; +my $Curdir = File::Spec->curdir; my $SAMPLE_TESTS = $ENV{PERL_CORE} - ? catdir(curdir(), 'lib', 'sample-tests') - : catdir(curdir(), 't', 'sample-tests'); + ? File::Spec->catdir($Curdir, 'lib', 'sample-tests') + : File::Spec->catdir($Curdir, 't', 'sample-tests'); -use strict; # For shutting up Test::Harness. # Has to work on 5.004 which doesn't have Tie::StdHandle. @@ -39,11 +40,11 @@ package main; use Test::More; -my $IsVMS = $^O eq 'VMS'; -my $IsMacOS = $^O eq 'MacOS'; +my $IsMacPerl = $^O eq 'MacOS'; +my $IsVMS = $^O eq 'VMS'; # VMS uses native, not POSIX, exit codes. -my $die_estat = $IsVMS ? 44 : $IsMacOS ? 0 : 1; +my $die_estat = $IsVMS ? 44 : 1; my %samples = ( simple => { @@ -415,7 +416,7 @@ my %samples = ( }, ); -plan tests => (keys(%samples) * 7) + 1; +plan tests => (keys(%samples) * 8) + 1; use Test::Harness; use_ok('Test::Harness'); @@ -423,22 +424,23 @@ use_ok('Test::Harness'); tie *NULL, 'My::Dev::Null' or die $!; -$SAMPLE_TESTS = VMS::Filespec::unixify($SAMPLE_TESTS) if $^O eq 'VMS'; - while (my($test, $expect) = each %samples) { # _run_all_tests() runs the tests but skips the formatting. my($totals, $failed); - my $warning; + my $warning = ''; + my $test_path = File::Spec->catfile($SAMPLE_TESTS, $test); + eval { select NULL; # _run_all_tests() isn't as quiet as it should be. local $SIG{__WARN__} = sub { $warning .= join '', @_; }; ($totals, $failed) = - Test::Harness::_run_all_tests($^O eq 'MacOS' ? - catfile($SAMPLE_TESTS, $test) : - "$SAMPLE_TESTS/$test"); + Test::Harness::_run_all_tests($test_path); }; select STDOUT; + # $? is unreliable in MacPerl, so we'll simply fudge it. + $failed->{estat} = $die_estat if $IsMacPerl and $failed; + SKIP: { skip "special tests for bailout", 1 unless $test eq 'bailout'; like( $@, '/Further testing stopped: GERONI/i' ); @@ -453,9 +455,7 @@ while (my($test, $expect) = each %samples) { is_deeply( {map { $_=>$totals->{$_} } keys %{$expect->{total}}}, $expect->{total}, "$test - totals" ); - is_deeply( {map { $_=>$failed->{$^O eq 'MacOS' ? - catfile($SAMPLE_TESTS, $test) : - "$SAMPLE_TESTS/$test"}{$_} } + is_deeply( {map { $_=>$failed->{$test_path}{$_} } keys %{$expect->{failed}}}, $expect->{failed}, "$test - failed" ); @@ -464,12 +464,16 @@ while (my($test, $expect) = each %samples) { SKIP: { skip "special tests for bignum", 1 unless $test eq 'bignum'; is( $warning, <