This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tidy t/io/layers.t
authorNicholas Clark <nick@ccl4.org>
Sun, 6 Mar 2011 21:41:01 +0000 (21:41 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 6 Mar 2011 22:48:16 +0000 (22:48 +0000)
Skip under minitest using skip_all_if_miniperl().
skip_all() once rather than skipping every test if Encode is not built, or
PerlIO is not available.

t/io/layers.t

index b0bcf1e..01e1864 100644 (file)
@@ -6,15 +6,13 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    unless (find PerlIO::Layer 'perlio') {
-       print "1..0 # Skip: not perlio\n";
-       exit 0;
-    }
-    eval 'use Encode';
-    if ($@ =~ /dynamic loading not available/) {
-        print "1..0 # miniperl cannot load Encode\n";
-       exit 0;
-    }
+    skip_all('not perlio') unless (find PerlIO::Layer 'perlio');
+    # FIXME - more of these could be tested without Encode or full perl
+    skip_all_if_miniperl("no dynamic loading on miniperl, no Encode");
+    require Config; Config->import;
+    skip_all('Encode was not built')
+       unless ($Config::Config{extensions} =~ /\bEncode\b/);
+
     # Makes testing easier.
     $ENV{PERLIO} = 'stdio' if exists $ENV{PERLIO} && $ENV{PERLIO} eq '';
     if (exists $ENV{PERLIO} && $ENV{PERLIO} !~ /^(stdio|perlio|mmap)$/) {
     # Makes testing easier.
     $ENV{PERLIO} = 'stdio' if exists $ENV{PERLIO} && $ENV{PERLIO} eq '';
     if (exists $ENV{PERLIO} && $ENV{PERLIO} !~ /^(stdio|perlio|mmap)$/) {
@@ -25,7 +23,6 @@ BEGIN {
     $PERLIO = exists $ENV{PERLIO} ? $ENV{PERLIO} : "(undef)";
 }
 
     $PERLIO = exists $ENV{PERLIO} ? $ENV{PERLIO} : "(undef)";
 }
 
-use Config;
 
 my $DOSISH    = $^O =~ /^(?:MSWin32|os2|dos|NetWare)$/ ? 1 : 0;
    $DOSISH    = 1 if !$DOSISH and $^O =~ /^uwin/;
 
 my $DOSISH    = $^O =~ /^(?:MSWin32|os2|dos|NetWare)$/ ? 1 : 0;
    $DOSISH    = 1 if !$DOSISH and $^O =~ /^uwin/;
@@ -60,12 +57,7 @@ print <<__EOH__;
 # UTF8_STDIN = $UTF8_STDIN
 __EOH__
 
 # UTF8_STDIN = $UTF8_STDIN
 __EOH__
 
-SKIP: {
-    # FIXME - more of these could be tested without Encode or full perl
-    skip("This perl does not have Encode", $NTEST)
-       unless " $Config{extensions} " =~ / Encode /;
-    skip("miniperl does not have Encode", $NTEST) if $ENV{PERL_CORE_MINITEST};
-
+{
     sub check {
        my ($result, $expected, $id) = @_;
        # An interesting dance follows where we try to make the following
     sub check {
        my ($result, $expected, $id) = @_;
        # An interesting dance follows where we try to make the following