perl 5.002beta1h patch: Configure
[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}
8d063cd8 34$bad = 0;
79072805 35$good = 0;
36$total = @ARGV;
8d063cd8 37while ($test = shift) {
fe14fcc3 38 if ($test =~ /^$/) {
378cc40b 39 next;
40 }
fe14fcc3 41 $te = $test;
42 chop($te);
43 print "$te" . '.' x (15 - length($te));
135863df 44 if ($sharpbang) {
a0d0e21e 45 open(results,"./$test |") || (print "can't run.\n");
135863df 46 } else {
378cc40b 47 open(script,"$test") || die "Can't run $test.\n";
135863df 48 $_ = <script>;
49 close(script);
50 if (/#!..perl(.*)/) {
51 $switch = $1;
52 } else {
53 $switch = '';
54 }
a0d0e21e 55 open(results,"./perl$switch $test |") || (print "can't run.\n");
135863df 56 }
8d063cd8 57 $ok = 0;
378cc40b 58 $next = 0;
8d063cd8 59 while (<results>) {
60 if ($verbose) {
61 print $_;
62 }
63 unless (/^#/) {
64 if (/^1\.\.([0-9]+)/) {
65 $max = $1;
2b317908 66 $totmax += $max;
67 $files += 1;
8d063cd8 68 $next = 1;
69 $ok = 1;
70 } else {
7e1cf235 71 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
8d063cd8 72 if (/^ok (.*)/ && $1 == $next) {
73 $next = $next + 1;
74 } else {
75 $ok = 0;
76 }
77 }
78 }
79 }
80 $next = $next - 1;
81 if ($ok && $next == $max) {
82 print "ok\n";
79072805 83 $good = $good + 1;
8d063cd8 84 } else {
85 $next += 1;
86 print "FAILED on test $next\n";
87 $bad = $bad + 1;
88 $_ = $test;
89 if (/^base/) {
378cc40b 90 die "Failed a basic test--cannot continue.\n";
8d063cd8 91 }
92 }
93}
94
95if ($bad == 0) {
96 if ($ok) {
97 print "All tests successful.\n";
98 } else {
378cc40b 99 die "FAILED--no tests were run for some reason.\n";
8d063cd8 100 }
101} else {
79072805 102 $pct = sprintf("%.2f", $good / $total * 100);
8d063cd8 103 if ($bad == 1) {
79072805 104 warn "Failed 1 test, $pct% okay.\n";
8d063cd8 105 } else {
79072805 106 die "Failed $bad/$total tests, $pct% okay.\n";
8d063cd8 107 }
108}
109($user,$sys,$cuser,$csys) = times;
2b317908 110print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n",
111 $user,$sys,$cuser,$csys,$files,$totmax);