In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/944f72d3c889b5f59497cfe286d5e11d4e2ff2b8?hp=95e2dc41df5a5b893cbc879e1fce6d1a86aa8711>
- Log ----------------------------------------------------------------- commit 944f72d3c889b5f59497cfe286d5e11d4e2ff2b8 Author: Nicholas Clark <[email protected]> Date: Mon Mar 7 19:37:13 2011 +0000 Replace quit() in t/op/groups.t with test.pl's skip_all() M t/op/groups.t commit 9c8416b2f966e2868aea89c8c24ff2774a4c6d75 Author: Nicholas Clark <[email protected]> Date: Mon Mar 7 19:25:13 2011 +0000 Add skip_all_without_config() to test.pl, and use it in 6 tests. This abstracts out the common idiom of loading Config, checking if a particular key is true, and if not implementing a "skip all" with an appropriate reason. M t/op/getpid.t M t/op/getppid.t M t/op/threads-dirh.t M t/op/threads.t M t/run/cloexec.t M t/run/runenv.t M t/test.pl commit 991b87804e286479de011fbef06fb073174aed77 Author: Nicholas Clark <[email protected]> Date: Mon Mar 7 18:10:45 2011 +0000 Refactor the startup logic in fflush.t to use skip_all() The tautological 3 way logic if (...) { print "1..7\n" } elsif (...) { print "1..7\n" } else { ... } had actually been in the test since it was first added in a43cb6b7285a7b60, although it was initially "1..4\n" in each block. Also use plan(), and set test.pl's idea of the current test before exiting. M t/io/fflush.t ----------------------------------------------------------------------- Summary of changes: t/io/fflush.t | 15 +++++---------- t/op/getpid.t | 9 +-------- t/op/getppid.t | 8 +------- t/op/groups.t | 22 ++++++---------------- t/op/threads-dirh.t | 5 +---- t/op/threads.t | 6 +----- t/run/cloexec.t | 6 +----- t/run/runenv.t | 7 ++----- t/test.pl | 15 +++++++++++++++ 9 files changed, 33 insertions(+), 60 deletions(-) diff --git a/t/io/fflush.t b/t/io/fflush.t index 056517f..4570f89 100644 --- a/t/io/fflush.t +++ b/t/io/fflush.t @@ -23,16 +23,10 @@ my $d_sfio = defined $Config{d_sfio} ? $Config{d_sfio} eq 'define' ? 1 : 0 : 0; my $fflushall = defined $Config{fflushall} ? $Config{fflushall} eq 'define' ? 1 : 0 : 0; my $d_fork = defined $Config{d_fork} ? $Config{d_fork} eq 'define' ? 1 : 0 : 0; -if ($useperlio || $fflushNULL || $d_sfio) { - print "1..7\n"; -} else { - if ($fflushall) { - print "1..7\n"; - } else { - print "1..0 # Skip: fflush(NULL) or equivalent not available\n"; - exit; - } -} +skip_all('fflush(NULL) or equivalent not available') + unless $useperlio || $fflushNULL || $d_sfio || $fflushall; + +plan(tests => 7); my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X; $runperl .= qq{ "-I../lib"}; @@ -135,3 +129,4 @@ while (<$CMD>) { } close $CMD; $t += 3; +curr_test($t); diff --git a/t/op/getpid.t b/t/op/getpid.t index b51b064..ac066d5 100644 --- a/t/op/getpid.t +++ b/t/op/getpid.t @@ -12,14 +12,7 @@ use strict; use Config; BEGIN { - if (!$Config{useithreads}) { - print "1..0 # Skip: no ithreads\n"; - exit; - } - if (!$Config{d_getppid}) { - print "1..0 # Skip: no getppid\n"; - exit; - } + skip_all_without_config($_) foreach qw(useithreads d_getppid); if ($ENV{PERL_CORE_MINITEST}) { print "1..0 # Skip: no dynamic loading on miniperl, no threads\n"; exit 0; diff --git a/t/op/getppid.t b/t/op/getppid.t index f4ebc7e..23428f0 100644 --- a/t/op/getppid.t +++ b/t/op/getppid.t @@ -13,16 +13,10 @@ BEGIN { } use strict; -use Config; BEGIN { - for my $syscall (qw(pipe fork waitpid getppid)) { - if (!$Config{"d_$syscall"}) { - print "1..0 # Skip: no $syscall\n"; - exit; - } - } require './test.pl'; + skip_all_without_config($_) foreach qw(d_pipe d_fork d_waitpid d_getppid); plan (8); } diff --git a/t/op/groups.t b/t/op/groups.t index d90884f..e6b2035 100644 --- a/t/op/groups.t +++ b/t/op/groups.t @@ -20,15 +20,11 @@ use strict; use Config (); use POSIX (); -unless (eval { my($foo) = getgrgid(0); 1 }) { - quit( "getgrgid() not implemented" ); -} +skip_all('getgrgid() not implemented') + unless eval { my($foo) = getgrgid(0); 1 }; -quit("No `id' or `groups'") if - $^O eq 'MSWin32' - || $^O eq 'NetWare' - || $^O eq 'VMS' - || $^O =~ /lynxos/i; +skip_all("No 'id' or 'groups'") if + $^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS' || $^O =~ /lynxos/i; Test(); exit; @@ -40,9 +36,9 @@ sub Test { # Get our supplementary groups from the system by running commands # like `id -a'. my ( $groups_command, $groups_string ) = system_groups() - or quit( "No `id' or `groups'" ); + or skip_all("No 'id' or 'groups'"); my @extracted_groups = extract_system_groups( $groups_string ) - or quit( "Can't parse `${groups_command}'" ); + or skip_all("Can't parse '${groups_command}'"); my $pwgid = $( + 0; my ($pwgnam) = getgrgid($pwgid); @@ -136,12 +132,6 @@ sub Test { return; } -# Cleanly abort this entire test file -sub quit { - print "1..0 # SKIP: @_\n"; - exit 0; -} - # Get the system groups and the command used to fetch them. # sub system_groups { diff --git a/t/op/threads-dirh.t b/t/op/threads-dirh.t index 900a62a..b481992 100644 --- a/t/op/threads-dirh.t +++ b/t/op/threads-dirh.t @@ -9,10 +9,7 @@ BEGIN { $| = 1; require Config; - if (!$Config::Config{useithreads}) { - print "1..0 # Skip: no ithreads\n"; - exit 0; - } + skip_all_without_config('useithreads'); skip_all_if_miniperl("no dynamic loading on miniperl, no threads"); plan(6); diff --git a/t/op/threads.t b/t/op/threads.t index 94dad6e..24e84e4 100644 --- a/t/op/threads.t +++ b/t/op/threads.t @@ -6,11 +6,7 @@ BEGIN { require './test.pl'; $| = 1; - require Config; - if (!$Config::Config{useithreads}) { - print "1..0 # Skip: no ithreads\n"; - exit 0; - } + skip_all_without_config('useithreads'); skip_all_if_miniperl("no dynamic loading on miniperl, no threads"); plan(24); diff --git a/t/run/cloexec.t b/t/run/cloexec.t index 314d5fa..486df1e 100644 --- a/t/run/cloexec.t +++ b/t/run/cloexec.t @@ -35,12 +35,8 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; - require Config; - if (!$Config::Config{'d_fcntl'}) { - print("1..0 # Skip: fcntl() is not available\n"); - exit(0); - } require './test.pl'; + skip_all_without_config('d_fcntl'); } use strict; diff --git a/t/run/runenv.t b/t/run/runenv.t index b3e47a6..cea2590 100644 --- a/t/run/runenv.t +++ b/t/run/runenv.t @@ -8,11 +8,8 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require Config; import Config; - unless ($Config{'d_fork'}) { - print "1..0 # Skip: no fork\n"; - exit 0; - } - require './test.pl' + require './test.pl'; + skip_all_without_config('d_fork'); } plan tests => 84; diff --git a/t/test.pl b/t/test.pl index a09c831..fa151ec 100644 --- a/t/test.pl +++ b/t/test.pl @@ -136,6 +136,21 @@ sub skip_all_without_perlio { skip_all('no PerlIO') unless PerlIO::Layer->find('perlio'); } +sub skip_all_without_config { + my ($key, $reason) = @_; + unless (eval 'require Config; 1') { + warn "test.pl had problems loading Config: $@"; + return; + } + return if $Config::Config{$key}; + unless (defined $reason) { + $key =~ s/^use//; + $key =~ s/^d_//; + $reason = "no $key"; + } + skip_all($reason); +} + sub _ok { my ($pass, $where, $name, @mess) = @_; # Do not try to microoptimize by factoring out the "not ". -- Perl5 Master Repository
