This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 4.0 patch 36: (combined patch)
[perl5.git] / t / TEST
CommitLineData
8d063cd8
LW
1#!./perl
2
2b317908 3# $RCSfile: TEST,v $$Revision: 4.0.1.1 $$Date: 91/06/07 11:59:30 $
8d063cd8
LW
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
LW
8$| = 1;
9
8d063cd8
LW
10if ($ARGV[0] eq '-v') {
11 $verbose = 1;
12 shift;
13}
14
378cc40b
LW
15chdir 't' if -f 't/TEST';
16
8d063cd8 17if ($ARGV[0] eq '') {
fe14fcc3
LW
18 @ARGV = split(/[ \n]/,
19 `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
8d063cd8
LW
20}
21
5303340c
LW
22open(CONFIG,"../config.sh");
23while (<CONFIG>) {
135863df
AB
24 if (/sharpbang='(.*)'/) {
25 $sharpbang = ($1 eq '#!');
26 last;
27 }
28}
8d063cd8
LW
29$bad = 0;
30while ($test = shift) {
fe14fcc3 31 if ($test =~ /^$/) {
378cc40b
LW
32 next;
33 }
fe14fcc3
LW
34 $te = $test;
35 chop($te);
36 print "$te" . '.' x (15 - length($te));
135863df 37 if ($sharpbang) {
378cc40b 38 open(results,"./$test|") || (print "can't run.\n");
135863df 39 } else {
378cc40b 40 open(script,"$test") || die "Can't run $test.\n";
135863df
AB
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 }
8d063cd8 50 $ok = 0;
378cc40b 51 $next = 0;
8d063cd8
LW
52 while (<results>) {
53 if ($verbose) {
54 print $_;
55 }
56 unless (/^#/) {
57 if (/^1\.\.([0-9]+)/) {
58 $max = $1;
2b317908
LW
59 $totmax += $max;
60 $files += 1;
8d063cd8
LW
61 $next = 1;
62 $ok = 1;
63 } else {
7e1cf235 64 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
8d063cd8
LW
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
LW
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
LW
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
LW
98 }
99}
100($user,$sys,$cuser,$csys) = times;
2b317908
LW
101print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n",
102 $user,$sys,$cuser,$csys,$files,$totmax);