This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Diagnostic cleanup
[perl5.git] / t / TEST
CommitLineData
8d063cd8
LW
1#!./perl
2
79072805 3# $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
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
4633a7c4
LW
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
LW
23 @ARGV = split(/[ \n]/,
24 `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
8d063cd8
LW
25}
26
5303340c
LW
27open(CONFIG,"../config.sh");
28while (<CONFIG>) {
135863df
AB
29 if (/sharpbang='(.*)'/) {
30 $sharpbang = ($1 eq '#!');
31 last;
32 }
33}
96e55a2d 34$sharpbang = 0 if $ENV{OS2_SHELL}; # OS/2
8d063cd8 35$bad = 0;
79072805
LW
36$good = 0;
37$total = @ARGV;
8d063cd8 38while ($test = shift) {
fe14fcc3 39 if ($test =~ /^$/) {
378cc40b
LW
40 next;
41 }
fe14fcc3
LW
42 $te = $test;
43 chop($te);
55497cff 44 print "$te" . '.' x (18 - length($te));
135863df 45 if ($sharpbang) {
a0d0e21e 46 open(results,"./$test |") || (print "can't run.\n");
135863df 47 } else {
378cc40b 48 open(script,"$test") || die "Can't run $test.\n";
135863df
AB
49 $_ = <script>;
50 close(script);
51 if (/#!..perl(.*)/) {
52 $switch = $1;
55497cff
PP
53 if ($^O eq 'VMS') {
54 # Must protect uppercase switches with "" on command line
55 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
56 }
135863df
AB
57 } else {
58 $switch = '';
59 }
a0d0e21e 60 open(results,"./perl$switch $test |") || (print "can't run.\n");
135863df 61 }
8d063cd8 62 $ok = 0;
378cc40b 63 $next = 0;
8d063cd8
LW
64 while (<results>) {
65 if ($verbose) {
66 print $_;
67 }
68 unless (/^#/) {
69 if (/^1\.\.([0-9]+)/) {
70 $max = $1;
2b317908
LW
71 $totmax += $max;
72 $files += 1;
8d063cd8
LW
73 $next = 1;
74 $ok = 1;
75 } else {
7e1cf235 76 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
8d063cd8
LW
77 if (/^ok (.*)/ && $1 == $next) {
78 $next = $next + 1;
79 } else {
80 $ok = 0;
81 }
82 }
83 }
84 }
85 $next = $next - 1;
86 if ($ok && $next == $max) {
bcce72a7
PP
87 if ($max) {
88 print "ok\n";
89 $good = $good + 1;
90 } else {
91 print "skipping test on this platform\n";
92 $files -= 1;
93 }
8d063cd8
LW
94 } else {
95 $next += 1;
96 print "FAILED on test $next\n";
97 $bad = $bad + 1;
98 $_ = $test;
99 if (/^base/) {
378cc40b 100 die "Failed a basic test--cannot continue.\n";
8d063cd8
LW
101 }
102 }
103}
104
105if ($bad == 0) {
106 if ($ok) {
107 print "All tests successful.\n";
108 } else {
378cc40b 109 die "FAILED--no tests were run for some reason.\n";
8d063cd8
LW
110 }
111} else {
79072805 112 $pct = sprintf("%.2f", $good / $total * 100);
8d063cd8 113 if ($bad == 1) {
79072805 114 warn "Failed 1 test, $pct% okay.\n";
8d063cd8 115 } else {
79072805 116 die "Failed $bad/$total tests, $pct% okay.\n";
8d063cd8
LW
117 }
118}
119($user,$sys,$cuser,$csys) = times;
2b317908
LW
120print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n",
121 $user,$sys,$cuser,$csys,$files,$totmax);