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