summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-07 13:33:48 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-07 13:33:48 +0000
commite05e9c3d01e748834948a3f9f9f62c9e72295130 (patch)
treef644689e9b3c8ceef84dc973c3866bf1508abc94
parentb6ae43b72863e12dd1cfc7eb414a05d61a20d8bd (diff)
downloadperl-e05e9c3d01e748834948a3f9f9f62c9e72295130.tar.gz
Add skip_all_without_perlio() to test.pl, and use it in 8 tests.
It's a common idiom in the tests. This makes it easier to find, read, and remove.
-rw-r--r--t/io/crlf.t8
-rw-r--r--t/io/layers.t2
-rw-r--r--t/io/perlio.t5
-rw-r--r--t/io/perlio_fail.t2
-rw-r--r--t/io/perlio_open.t2
-rw-r--r--t/io/utf8.t7
-rw-r--r--t/op/incfilter.t5
-rw-r--r--t/run/switchC.t5
-rw-r--r--t/test.pl4
9 files changed, 15 insertions, 25 deletions
diff --git a/t/io/crlf.t b/t/io/crlf.t
index 7eb9a78964..ff0f208554 100644
--- a/t/io/crlf.t
+++ b/t/io/crlf.t
@@ -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) = @_;
diff --git a/t/io/layers.t b/t/io/layers.t
index cb7cbefea8..4e4204377e 100644
--- a/t/io/layers.t
+++ b/t/io/layers.t
@@ -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');
diff --git a/t/io/perlio.t b/t/io/perlio.t
index 8b1cff3995..1a330f4367 100644
--- a/t/io/perlio.t
+++ b/t/io/perlio.t
@@ -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;
diff --git a/t/io/perlio_fail.t b/t/io/perlio_fail.t
index 56e3d1d5a5..6bc9b17b27 100644
--- a/t/io/perlio_fail.t
+++ b/t/io/perlio_fail.t
@@ -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);
}
diff --git a/t/io/perlio_open.t b/t/io/perlio_open.t
index 7bd9a70350..9969796a36 100644
--- a/t/io/perlio_open.t
+++ b/t/io/perlio_open.t
@@ -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?
}
diff --git a/t/io/utf8.t b/t/io/utf8.t
index 07f829b527..4b01747943 100644
--- a/t/io/utf8.t
+++ b/t/io/utf8.t
@@ -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);
diff --git a/t/op/incfilter.t b/t/op/incfilter.t
index d0e8f75360..74675a2c12 100644
--- a/t/op/incfilter.t
+++ b/t/op/incfilter.t
@@ -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;
diff --git a/t/run/switchC.t b/t/run/switchC.t
index 9297286c69..5223b001c8 100644
--- a/t/run/switchC.t
+++ b/t/run/switchC.t
@@ -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');
}
diff --git a/t/test.pl b/t/test.pl
index 9958356285..a09c831cb4 100644
--- 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 ".