This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 3.0 patch #44 patch #42, continued
[perl5.git] / t / TEST
CommitLineData
8d063cd8
LW
1#!./perl
2
7e1cf235 3# $Header: TEST,v 3.0.1.3 91/01/11 18:28:17 lwall Locked $
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 '') {
5303340c 18 @ARGV = split(/[ \n]/,`echo base.* comp.* cmd.* io.* op.* lib.*`);
8d063cd8
LW
19}
20
5303340c
LW
21open(CONFIG,"../config.sh");
22while (<CONFIG>) {
135863df
AB
23 if (/sharpbang='(.*)'/) {
24 $sharpbang = ($1 eq '#!');
25 last;
26 }
27}
8d063cd8
LW
28$bad = 0;
29while ($test = shift) {
378cc40b
LW
30 if ($test =~ /\.orig$/) {
31 next;
32 }
bf38876a
LW
33 if ($test =~ /\.rej$/) {
34 next;
35 }
a687059c
LW
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
AB
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
LW
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 {
7e1cf235 65 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
8d063cd8
LW
66 if (/^ok (.*)/ && $1 == $next) {
67 $next = $next + 1;
68 } else {
69 $ok = 0;
70 }
71 }
72 }
73 }
74 $next = $next - 1;
75 if ($ok && $next == $max) {
76 print "ok\n";
77 } else {
78 $next += 1;
79 print "FAILED on test $next\n";
80 $bad = $bad + 1;
81 $_ = $test;
82 if (/^base/) {
378cc40b 83 die "Failed a basic test--cannot continue.\n";
8d063cd8
LW
84 }
85 }
86}
87
88if ($bad == 0) {
89 if ($ok) {
90 print "All tests successful.\n";
91 } else {
378cc40b 92 die "FAILED--no tests were run for some reason.\n";
8d063cd8
LW
93 }
94} else {
95 if ($bad == 1) {
378cc40b 96 die "Failed 1 test.\n";
8d063cd8 97 } else {
378cc40b 98 die "Failed $bad tests.\n";
8d063cd8
LW
99 }
100}
101($user,$sys,$cuser,$csys) = times;
102print sprintf("u=%g s=%g cu=%g cs=%g\n",$user,$sys,$cuser,$csys);