Re: 5.003_09 and QNX
[p5sagit/p5-mst-13.2.git] / t / TEST
CommitLineData
8d063cd8 1#!./perl
2
79072805 3# $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
8d063cd8 4
5# This is written in a peculiar style, since we're trying to avoid
6# most of the constructs we'll be testing for.
7
a687059c 8$| = 1;
9
8d063cd8 10if ($ARGV[0] eq '-v') {
11 $verbose = 1;
12 shift;
13}
14
378cc40b 15chdir 't' if -f 't/TEST';
16
4633a7c4 17die "You need to run \"make test\" first to set things up.\n"
18 unless -e 'perl' or -e 'perl.exe';
19
20$ENV{EMXSHELL} = 'sh'; # For OS/2
748a9306 21
8d063cd8 22if ($ARGV[0] eq '') {
fe14fcc3 23 @ARGV = split(/[ \n]/,
24 `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
8d063cd8 25}
26
5303340c 27open(CONFIG,"../config.sh");
28while (<CONFIG>) {
135863df 29 if (/sharpbang='(.*)'/) {
30 $sharpbang = ($1 eq '#!');
31 last;
32 }
33}
96e55a2d 34$sharpbang = 0 if $ENV{OS2_SHELL}; # OS/2
c5117498 35$sharpbang = 0 if ($^O eq 'qnx'); # QNX
8d063cd8 36$bad = 0;
79072805 37$good = 0;
38$total = @ARGV;
8d063cd8 39while ($test = shift) {
fe14fcc3 40 if ($test =~ /^$/) {
378cc40b 41 next;
42 }
fe14fcc3 43 $te = $test;
44 chop($te);
55497cff 45 print "$te" . '.' x (18 - length($te));
135863df 46 if ($sharpbang) {
a0d0e21e 47 open(results,"./$test |") || (print "can't run.\n");
135863df 48 } else {
378cc40b 49 open(script,"$test") || die "Can't run $test.\n";
135863df 50 $_ = <script>;
51 close(script);
52 if (/#!..perl(.*)/) {
53 $switch = $1;
55497cff 54 if ($^O eq 'VMS') {
55 # Must protect uppercase switches with "" on command line
56 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
57 }
135863df 58 } else {
59 $switch = '';
60 }
a0d0e21e 61 open(results,"./perl$switch $test |") || (print "can't run.\n");
135863df 62 }
8d063cd8 63 $ok = 0;
378cc40b 64 $next = 0;
8d063cd8 65 while (<results>) {
66 if ($verbose) {
67 print $_;
68 }
69 unless (/^#/) {
70 if (/^1\.\.([0-9]+)/) {
71 $max = $1;
2b317908 72 $totmax += $max;
73 $files += 1;
8d063cd8 74 $next = 1;
75 $ok = 1;
76 } else {
7e1cf235 77 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
8d063cd8 78 if (/^ok (.*)/ && $1 == $next) {
79 $next = $next + 1;
80 } else {
81 $ok = 0;
82 }
83 }
84 }
85 }
86 $next = $next - 1;
87 if ($ok && $next == $max) {
bcce72a7 88 if ($max) {
89 print "ok\n";
90 $good = $good + 1;
91 } else {
92 print "skipping test on this platform\n";
93 $files -= 1;
94 }
8d063cd8 95 } else {
96 $next += 1;
97 print "FAILED on test $next\n";
98 $bad = $bad + 1;
99 $_ = $test;
100 if (/^base/) {
378cc40b 101 die "Failed a basic test--cannot continue.\n";
8d063cd8 102 }
103 }
104}
105
106if ($bad == 0) {
107 if ($ok) {
108 print "All tests successful.\n";
109 } else {
378cc40b 110 die "FAILED--no tests were run for some reason.\n";
8d063cd8 111 }
112} else {
79072805 113 $pct = sprintf("%.2f", $good / $total * 100);
8d063cd8 114 if ($bad == 1) {
79072805 115 warn "Failed 1 test, $pct% okay.\n";
8d063cd8 116 } else {
79072805 117 die "Failed $bad/$total tests, $pct% okay.\n";
8d063cd8 118 }
119}
120($user,$sys,$cuser,$csys) = times;
2b317908 121print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n",
122 $user,$sys,$cuser,$csys,$files,$totmax);