This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add skip_all_without_perlio() to test.pl, and use it in 8 tests.
authorNicholas Clark <nick@ccl4.org>
Mon, 7 Mar 2011 13:33:48 +0000 (13:33 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 7 Mar 2011 13:33:48 +0000 (13:33 +0000)
It's a common idiom in the tests. This makes it easier to find, read, and
remove.

t/io/crlf.t
t/io/layers.t
t/io/perlio.t
t/io/perlio_fail.t
t/io/perlio_open.t
t/io/utf8.t
t/op/incfilter.t
t/run/switchC.t
t/test.pl

index 7eb9a78..ff0f208 100644 (file)
@@ -3,15 +3,16 @@
 BEGIN {
     chdir 't' if -d 't';
     @INC = qw(. ../lib);
+    require "test.pl";
+    skip_all_without_perlio();
 }
 
 use Config;
 
-require "test.pl";
 
 my $file = tempfile();
 
-if (find PerlIO::Layer 'perlio') {
+{
     plan(tests => 16);
     ok(open(FOO,">:crlf",$file));
     ok(print FOO 'a'.((('a' x 14).qq{\n}) x 2000) || close(FOO));
@@ -70,9 +71,6 @@ if (find PerlIO::Layer 'perlio') {
        }
     }
 }
-else {
-    skip_all("No perlio, so no :crlf");
-}
 
 sub count_chars {
     my($text, $chars) = @_;
index cb7cbef..4e42043 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    skip_all('not perlio') unless (find PerlIO::Layer 'perlio');
+    skip_all_without_perlio();
     # FIXME - more of these could be tested without Encode or full perl
     skip_all_if_miniperl("no dynamic loading on miniperl, no Encode");
     skip_all_without_extension('Encode');
index 8b1cff3..1a330f4 100644 (file)
@@ -2,11 +2,8 @@ BEGIN {
        chdir 't' if -d 't';
        @INC = '../lib';
        require Config; import Config;
-       unless (find PerlIO::Layer 'perlio') {
-           print "1..0 # Skip: PerlIO not used\n";
-           exit 0;
-       }
        require './test.pl';
+       skip_all_without_perlio();
 }
 
 plan tests => 42;
index 56e3d1d..6bc9b17 100644 (file)
@@ -4,7 +4,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require "../t/test.pl";
-    skip_all("No perlio") unless (find PerlIO::Layer 'perlio');
+    skip_all_without_perlio();
     plan (15);
 }
 
index 7bd9a70..9969796 100644 (file)
@@ -4,7 +4,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    skip_all('not perlio') unless (find PerlIO::Layer 'perlio');
+    skip_all_without_perlio();
     skip_all_if_miniperl("no dynamic loading on miniperl, no Fcntl");
     skip_all_without_extension('Fcntl'); # how did you get this far?
 }
index 07f829b..4b01747 100644 (file)
@@ -3,15 +3,12 @@
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
-    unless (find PerlIO::Layer 'perlio') {
-       print "1..0 # Skip: not perlio\n";
-       exit 0;
-    }
+    require './test.pl';
+    skip_all_without_perlio();
 }
 
 no utf8; # needed for use utf8 not griping about the raw octets
 
-BEGIN { require "./test.pl"; }
 
 plan(tests => 55);
 
index d0e8f75..74675a2 100644 (file)
@@ -7,10 +7,7 @@ BEGIN {
     @INC = qw(. ../lib);
     require 'test.pl';
     skip_all_if_miniperl('no dynamic loading on miniperl, no Filter::Util::Call');
-    unless (find PerlIO::Layer 'perlio') {
-       print "1..0 # Skip: not perlio\n";
-       exit 0;
-    }
+    skip_all_without_perlio();
 }
 use strict;
 use Config;
index 9297286..5223b00 100644 (file)
@@ -7,10 +7,7 @@ BEGIN {
     @INC = '../lib';
     require "./test.pl";
 
-    unless (find PerlIO::Layer 'perlio') {
-       print "1..0 # Skip: not perlio\n";
-       exit 0;
-    }
+    skip_all_without_perlio();
     skip_all_if_miniperl('-C and $ENV{PERL_UNICODE} are disabled on miniperl');
 }
 
index 9958356..a09c831 100644 (file)
--- a/t/test.pl
+++ b/t/test.pl
@@ -132,6 +132,10 @@ sub skip_all_without_extension {
     skip_all("$extension was not built");
 }
 
+sub skip_all_without_perlio {
+    skip_all('no PerlIO') unless PerlIO::Layer->find('perlio');
+}
+
 sub _ok {
     my ($pass, $where, $name, @mess) = @_;
     # Do not try to microoptimize by factoring out the "not ".