perl 3.0 patch #22 patch #19, continued
[p5sagit/p5-mst-13.2.git] / t / TEST
CommitLineData
8d063cd8 1#!./perl
2
bf38876a 3# $Header: TEST,v 3.0.1.1 89/11/11 04:58:01 lwall Locked $
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
8d063cd8 17if ($ARGV[0] eq '') {
18 @ARGV = split(/[ \n]/,`echo base.* comp.* cmd.* io.* op.*`);
19}
20
135863df 21open(config,"../config.sh");
22while (<config>) {
23 if (/sharpbang='(.*)'/) {
24 $sharpbang = ($1 eq '#!');
25 last;
26 }
27}
8d063cd8 28$bad = 0;
29while ($test = shift) {
378cc40b 30 if ($test =~ /\.orig$/) {
31 next;
32 }
bf38876a 33 if ($test =~ /\.rej$/) {
34 next;
35 }
a687059c 36 if ($test =~ /~$/) {
37 next;
38 }
39 print "$test" . '.' x (16 - length($test));
135863df 40 if ($sharpbang) {
378cc40b 41 open(results,"./$test|") || (print "can't run.\n");
135863df 42 } else {
378cc40b 43 open(script,"$test") || die "Can't run $test.\n";
135863df 44 $_ = <script>;
45 close(script);
46 if (/#!..perl(.*)/) {
47 $switch = $1;
48 } else {
49 $switch = '';
50 }
51 open(results,"./perl$switch $test|") || (print "can't run.\n");
52 }
8d063cd8 53 $ok = 0;
378cc40b 54 $next = 0;
8d063cd8 55 while (<results>) {
56 if ($verbose) {
57 print $_;
58 }
59 unless (/^#/) {
60 if (/^1\.\.([0-9]+)/) {
61 $max = $1;
62 $next = 1;
63 $ok = 1;
64 } else {
65 if (/^ok (.*)/ && $1 == $next) {
66 $next = $next + 1;
67 } else {
68 $ok = 0;
69 }
70 }
71 }
72 }
73 $next = $next - 1;
74 if ($ok && $next == $max) {
75 print "ok\n";
76 } else {
77 $next += 1;
78 print "FAILED on test $next\n";
79 $bad = $bad + 1;
80 $_ = $test;
81 if (/^base/) {
378cc40b 82 die "Failed a basic test--cannot continue.\n";
8d063cd8 83 }
84 }
85}
86
87if ($bad == 0) {
88 if ($ok) {
89 print "All tests successful.\n";
90 } else {
378cc40b 91 die "FAILED--no tests were run for some reason.\n";
8d063cd8 92 }
93} else {
94 if ($bad == 1) {
378cc40b 95 die "Failed 1 test.\n";
8d063cd8 96 } else {
378cc40b 97 die "Failed $bad tests.\n";
8d063cd8 98 }
99}
100($user,$sys,$cuser,$csys) = times;
101print sprintf("u=%g s=%g cu=%g cs=%g\n",$user,$sys,$cuser,$csys);