summaryrefslogtreecommitdiff
path: root/ext/POSIX
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-08-28 00:44:15 +0100
committerNicholas Clark <nick@ccl4.org>2009-08-28 00:44:15 +0100
commit2adbc9b6919cad1240a834325b355e9b2d5efd67 (patch)
treea8ca75ac9ed7b8284a533b3f24c8407110d0c546 /ext/POSIX
parentd418880282b996e8cb066a570596b473fa7900da (diff)
downloadperl-2adbc9b6919cad1240a834325b355e9b2d5efd67.tar.gz
Make extensions in ext run their tests from the extension's own directory.
Inspired by, and in parts borrows from, Schwern's branch on github, but takes a slightly different approach in places. Not quite perfect yet - ext/File-Glob still runs from t, at least one FIXME needs fixing, and the changes to dual-life modules' tests need to be filtered back upstream, and possibly modified to suit their respective authors. But it works.
Diffstat (limited to 'ext/POSIX')
-rw-r--r--ext/POSIX/t/is.t4
-rw-r--r--ext/POSIX/t/posix.t17
-rw-r--r--ext/POSIX/t/sigaction.t5
-rw-r--r--ext/POSIX/t/sysconf.t5
-rw-r--r--ext/POSIX/t/taint.t6
-rw-r--r--ext/POSIX/t/termios.t5
-rw-r--r--ext/POSIX/t/waitpid.t5
7 files changed, 9 insertions, 38 deletions
diff --git a/ext/POSIX/t/is.t b/ext/POSIX/t/is.t
index 489b3a9638..cb36fb5692 100644
--- a/ext/POSIX/t/is.t
+++ b/ext/POSIX/t/is.t
@@ -1,8 +1,6 @@
#!./perl -w
BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
require Config; import Config;
if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
print "1..0\n";
@@ -72,7 +70,7 @@ foreach my $s (keys %classes) {
# Expected number of tests is one each for every combination of a
# known is<xxx> function and string listed above.
-require './test.pl';
+require '../../t/test.pl';
plan(tests => keys(%classes) * keys(%functions));
diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t
index 93665325dd..0800f914b5 100644
--- a/ext/POSIX/t/posix.t
+++ b/ext/POSIX/t/posix.t
@@ -1,8 +1,6 @@
#!./perl
BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
require Config; import Config;
if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
print "1..0\n";
@@ -10,7 +8,7 @@ BEGIN {
}
}
-BEGIN { require "./test.pl"; }
+BEGIN { require "../../t/test.pl"; }
plan(tests => 66);
use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write
@@ -50,9 +48,9 @@ if ($Is_VMS) {
}
-ok( $testfd = open("TEST", O_RDONLY, 0), 'O_RDONLY with open' );
+ok( $testfd = open("Makefile.PL", O_RDONLY, 0), 'O_RDONLY with open' );
read($testfd, $buffer, 4) if $testfd > 2;
-is( $buffer, "#!./", ' with read' );
+is( $buffer, "# Ex", ' with read' );
TODO:
{
@@ -147,14 +145,11 @@ SKIP: {
}
my $pat;
-if ($Is_MacOS) {
- $pat = qr/:t:$/;
-}
-elsif ( $unix_mode ) {
- $pat = qr#[\\/]t$#i;
+if ( $unix_mode ) {
+ $pat = qr#[\\/]POSIX$#i;
}
else {
- $pat = qr/\.T]/i;
+ $pat = qr/\.POSIX]/i;
}
like( getcwd(), qr/$pat/, 'getcwd' );
diff --git a/ext/POSIX/t/sigaction.t b/ext/POSIX/t/sigaction.t
index 0d532b2472..fd6cf2de65 100644
--- a/ext/POSIX/t/sigaction.t
+++ b/ext/POSIX/t/sigaction.t
@@ -1,10 +1,5 @@
#!./perl
-BEGIN {
- chdir 't' if -d 't';
- unshift @INC, '../lib';
-}
-
BEGIN{
# Don't do anything if POSIX is missing, or sigaction missing.
use Config;
diff --git a/ext/POSIX/t/sysconf.t b/ext/POSIX/t/sysconf.t
index f11841c7fb..2dc9762977 100644
--- a/ext/POSIX/t/sysconf.t
+++ b/ext/POSIX/t/sysconf.t
@@ -1,11 +1,6 @@
#!perl -T
BEGIN {
- if ($ENV{PERL_CORE}) {
- chdir 't';
- @INC = '../lib';
- }
-
use Config;
use Test::More;
plan skip_all => "POSIX is unavailable" if $Config{'extensions'} !~ m!\bPOSIX\b!;
diff --git a/ext/POSIX/t/taint.t b/ext/POSIX/t/taint.t
index a88f6561fb..3ca01743e0 100644
--- a/ext/POSIX/t/taint.t
+++ b/ext/POSIX/t/taint.t
@@ -1,8 +1,6 @@
#!./perl -Tw
BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
require Config; import Config;
if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
print "1..0\n";
@@ -28,7 +26,7 @@ my $testfd;
my $TAINT = substr($^X, 0, 0);
-my $file = 'TEST';
+my $file = 'POSIX.xs';
eval { mkfifo($TAINT. $file, 0) };
like($@, qr/^Insecure dependency/, 'mkfifo with tainted data');
@@ -40,7 +38,7 @@ eval { $testfd = open($file, O_RDONLY, 0) };
is($@, "", 'open with untainted data');
read($testfd, $buffer, 2) if $testfd > 2;
-is( $buffer, "#!", ' read' );
+is( $buffer, "#d", ' read' );
ok(tainted($buffer), ' scalar tainted');
TODO: {
diff --git a/ext/POSIX/t/termios.t b/ext/POSIX/t/termios.t
index 2fbff9665a..7c3deb6678 100644
--- a/ext/POSIX/t/termios.t
+++ b/ext/POSIX/t/termios.t
@@ -1,11 +1,6 @@
#!perl -T
BEGIN {
- if ($ENV{PERL_CORE}) {
- chdir 't';
- @INC = '../lib';
- }
-
use Config;
use Test::More;
plan skip_all => "POSIX is unavailable"
diff --git a/ext/POSIX/t/waitpid.t b/ext/POSIX/t/waitpid.t
index c36a611bfc..105b1be1b2 100644
--- a/ext/POSIX/t/waitpid.t
+++ b/ext/POSIX/t/waitpid.t
@@ -1,9 +1,4 @@
BEGIN {
- chdir 't' if -d 't';
- unshift @INC, '../lib';
-}
-
-BEGIN {
use Config;
unless ($Config{d_fork}) {
print "1..0 # Skip: no fork\n";