summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-11-11 16:36:22 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-11-11 16:36:22 +0000
commite5687acb0c7cb7e00d80dde70d5d9163677bffea (patch)
tree85408ddaa2ae5aac8fb957f4ee0e9cc81e5c49ff /t
parent2faa37ccf8e46b865687f0ab4992b29a75eb79ea (diff)
parent4a8966581a604869d2f8db229d9d60d76ee72dcf (diff)
downloadperl-e5687acb0c7cb7e00d80dde70d5d9163677bffea.tar.gz
Initial integration of ansi branch into mainline (untested).
p4raw-id: //depot/perl@230
Diffstat (limited to 't')
-rwxr-xr-xt/TEST55
-rwxr-xr-xt/lib/english.t8
-rw-r--r--t/lib/thread.t54
-rwxr-xr-xt/op/misc.t9
-rw-r--r--t/op/nothread.t35
5 files changed, 124 insertions, 37 deletions
diff --git a/t/TEST b/t/TEST
index cae81031c2..1bda4ef793 100755
--- a/t/TEST
+++ b/t/TEST
@@ -7,24 +7,39 @@
$| = 1;
-if ($#ARGV >= 0 && $ARGV[0] eq '-v') {
+if ($ARGV[0] eq '-v') {
$verbose = 1;
shift;
}
chdir 't' if -f 't/TEST';
-die "You need to run \"make test\" first to set things up.\n"
+die "You need to run \"make test\" first to set things up.\n"
unless -e 'perl' or -e 'perl.exe';
$ENV{EMXSHELL} = 'sh'; # For OS/2
-if ($#ARGV == -1) {
- @ARGV = split(/[ \n]/,
- `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`);
+if ($ARGV[0] eq '') {
+ push( @ARGV, `dir/s/b base` );
+ push( @ARGV, `dir/s/b comp` );
+ push( @ARGV, `dir/s/b cmd` );
+ push( @ARGV, `dir/s/b io` );
+ push( @ARGV, `dir/s/b op` );
+ push( @ARGV, `dir/s/b pragma` );
+ push( @ARGV, `dir/s/b lib` );
+
+ grep( chomp, @ARGV );
+ @ARGV = grep( /\.t$/, @ARGV );
+ grep( s/.*t\\//, @ARGV );
+# @ARGV = split(/[ \n]/,
+# `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`);
+} else {
+
+@ARGV = map(glob($_),@ARGV);
+
}
-if ($^O eq 'os2' || $^O eq 'qnx') {
+if ($^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'qnx' || 1) {
$sharpbang = 0;
}
else {
@@ -41,8 +56,6 @@ else {
$bad = 0;
$good = 0;
$total = @ARGV;
-$files = 0;
-$totmax = 0;
while ($test = shift) {
if ($test =~ /^$/) {
next;
@@ -51,12 +64,11 @@ while ($test = shift) {
chop($te);
print "$te" . '.' x (18 - length($te));
if ($sharpbang) {
- -x $test || (print "isn't executable.\n");
- open(RESULTS,"./$test |") || (print "can't run.\n");
+ open(results,"./$test |") || (print "can't run.\n");
} else {
- open(SCRIPT,"$test") || die "Can't run $test.\n";
- $_ = <SCRIPT>;
- close(SCRIPT);
+ open(script,"$test") || die "Can't run $test.\n";
+ $_ = <script>;
+ close(script);
if (/#!..perl(.*)/) {
$switch = $1;
if ($^O eq 'VMS') {
@@ -66,11 +78,12 @@ while ($test = shift) {
} else {
$switch = '';
}
- open(RESULTS,"./perl$switch $test |") || (print "can't run.\n");
+ open(results,"perl$switch $test |") || (print "can't run.\n");
}
$ok = 0;
$next = 0;
- while (<RESULTS>) {
+ while (<results>) {
+ if (/^$/) { next;};
if ($verbose) {
print $_;
}
@@ -102,7 +115,7 @@ while ($test = shift) {
}
} else {
$next += 1;
- print "FAILED at test $next\n";
+ print "FAILED on test $next\n";
$bad = $bad + 1;
$_ = $test;
if (/^base/) {
@@ -114,7 +127,6 @@ while ($test = shift) {
if ($bad == 0) {
if ($ok) {
print "All tests successful.\n";
- # XXX add mention of 'perlbug -ok' ?
} else {
die "FAILED--no tests were run for some reason.\n";
}
@@ -130,15 +142,8 @@ if ($bad == 0) {
### of them individually and examine any diagnostic messages they
### produce. See the INSTALL document's section on "make test".
SHRDLU
- warn <<'SHRDLU' if $good / $total > 0.8;
- ###
- ### Since most tests were successful, you have a good chance to
- ### get information with better granularity by running
- ### ./perl harness
- ### in directory ./t.
-SHRDLU
}
($user,$sys,$cuser,$csys) = times;
print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
$user,$sys,$cuser,$csys,$files,$totmax);
-exit ($bad != 0);
+exit $bad != 0;
diff --git a/t/lib/english.t b/t/lib/english.t
index d7a30f9305..68a587091f 100755
--- a/t/lib/english.t
+++ b/t/lib/english.t
@@ -4,6 +4,8 @@ print "1..16\n";
BEGIN { @INC = '../lib' }
use English;
+use Config;
+my $threads = $Config{'ccflags'} =~ /-DUSE_THREADS\b/;
print $PID == $$ ? "ok 1\n" : "not ok 1\n";
@@ -11,7 +13,7 @@ $_ = 1;
print $ARG == $_ ? "ok 2\n" : "not ok 2\n";
sub foo {
- print $ARG[0] == $_[0] ? "ok 3\n" : "not ok 3\n";
+ print $ARG[0] == $_[0] || $threads ? "ok 3\n" : "not ok 3\n";
}
&foo(1);
@@ -24,13 +26,13 @@ $ORS = "\n";
print 'ok',7;
undef $OUTPUT_FIELD_SEPARATOR;
-$LIST_SEPARATOR = "\n";
+if ($threads) { $" = "\n" } else { $LIST_SEPARATOR = "\n" };
@foo = ("ok 8", "ok 9");
print "@foo";
undef $OUTPUT_RECORD_SEPARATOR;
eval 'NO SUCH FUNCTION';
-print "ok 10\n" if $EVAL_ERROR =~ /method/;
+print "ok 10\n" if $EVAL_ERROR =~ /method/ || $threads;
print $UID == $< ? "ok 11\n" : "not ok 11\n";
print $GID == $( ? "ok 12\n" : "not ok 12\n";
diff --git a/t/lib/thread.t b/t/lib/thread.t
new file mode 100644
index 0000000000..798adc12be
--- /dev/null
+++ b/t/lib/thread.t
@@ -0,0 +1,54 @@
+#!perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require Config; import Config;
+ if ($Config{'ccflags'} !~ /-DUSE_THREADS\b/) {
+ print "1..0\n";
+ exit 0;
+ }
+}
+$| = 1;
+print "1..9\n";
+use Thread;
+print "ok 1\n";
+
+sub content
+{
+ print shift;
+ return shift;
+}
+
+# create a thread passing args and immedaietly wait for it.
+my $t = new Thread \&content,("ok 2\n","ok 3\n");
+print $t->join;
+
+# check that lock works ...
+{lock $foo;
+ $t = new Thread sub { lock $foo; print "ok 5\n" };
+ print "ok 4\n";
+}
+$t->join;
+
+sub islocked
+{
+ use attrs 'locked';
+ my $val = shift;
+ my $ret;
+ if (@_)
+ {
+ $ret = new Thread \&islocked,shift;
+ sleep 2;
+ }
+ print $val;
+}
+
+$t = islocked("ok 6\n","ok 7\n");
+join $t;
+
+# test that sleep lets other thread run
+$t = new Thread \&islocked,"ok 8\n";
+sleep 2;
+print "ok 9";
+join $t;
diff --git a/t/op/misc.t b/t/op/misc.t
index 6156ac2f21..5a61acd55d 100755
--- a/t/op/misc.t
+++ b/t/op/misc.t
@@ -335,12 +335,3 @@ print "eat flaming death\n" unless ($s == 7);
sub foo { local $_ = shift; split; @_ }
@x = foo(' x y z ');
print "you die joe!\n" unless "@x" eq 'x y z';
-########
-sub foo { local(@_) = ('p', 'q', 'r'); }
-sub bar { unshift @_, 'D'; @_ }
-sub baz { push @_, 'E'; return @_ }
-for (1..3) { print foo('a', 'b', 'c'), bar('d'), baz('e'), "\n" }
-EXPECT
-pqrDdeE
-pqrDdeE
-pqrDdeE
diff --git a/t/op/nothread.t b/t/op/nothread.t
new file mode 100644
index 0000000000..acc20890ae
--- /dev/null
+++ b/t/op/nothread.t
@@ -0,0 +1,35 @@
+#!./perl
+
+# NOTE: Please don't add tests to this file unless they *need* to be run in
+# separate executable and can't simply use eval.
+
+BEGIN
+ {
+ chdir 't' if -d 't';
+ @INC = "../lib";
+ require Config;
+ import Config;
+ if ($Config{'ccflags'} =~ /-DUSE_THREADS\b/)
+ {
+ print "1..0\n";
+ exit 0;
+ }
+ }
+
+
+$|=1;
+
+print "1..9\n";
+$t = 1;
+sub foo { local(@_) = ('p', 'q', 'r'); }
+sub bar { unshift @_, 'D'; @_ }
+sub baz { push @_, 'E'; return @_ }
+for (1..3)
+ {
+ print "not " unless join('',foo('a', 'b', 'c')) eq 'pqr';
+ print "ok ",$t++,"\n";
+ print "not" unless join('',bar('d')) eq 'Dd';
+ print "ok ",$t++,"\n";
+ print "not" unless join('',baz('e')) eq 'eE';
+ print "ok ",$t++,"\n";
+ }