This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix up ansiperl integration. Back to passing all expected tests
[perl5.git] / t / TEST
CommitLineData
8d063cd8
LW
1#!./perl
2
f46c10df 3# Last change: Fri Jan 10 09:57:03 WET 1997
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
e77eedc2 10if ($ARGV[0] eq '-v') {
8d063cd8
LW
11 $verbose = 1;
12 shift;
13}
14
378cc40b
LW
15chdir 't' if -f 't/TEST';
16
e77eedc2 17die "You need to run \"make test\" first to set things up.\n"
4633a7c4
LW
18 unless -e 'perl' or -e 'perl.exe';
19
20$ENV{EMXSHELL} = 'sh'; # For OS/2
748a9306 21
e77eedc2
NIS
22if ($ARGV[0] eq '') {
23 push( @ARGV, `dir/s/b base` );
24 push( @ARGV, `dir/s/b comp` );
25 push( @ARGV, `dir/s/b cmd` );
26 push( @ARGV, `dir/s/b io` );
27 push( @ARGV, `dir/s/b op` );
28 push( @ARGV, `dir/s/b pragma` );
29 push( @ARGV, `dir/s/b lib` );
30
31 grep( chomp, @ARGV );
32 @ARGV = grep( /\.t$/, @ARGV );
33 grep( s/.*t\\//, @ARGV );
34# @ARGV = split(/[ \n]/,
35# `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`);
36} else {
37
38@ARGV = map(glob($_),@ARGV);
39
8d063cd8
LW
40}
41
e77eedc2 42if ($^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'qnx' || 1) {
ff68c719
PP
43 $sharpbang = 0;
44}
45else {
46 open(CONFIG, "../config.sh");
47 while (<CONFIG>) {
48 if (/sharpbang='(.*)'/) {
49 $sharpbang = ($1 eq '#!');
50 last;
51 }
135863df 52 }
ff68c719 53 close(CONFIG);
135863df 54}
ff68c719 55
8d063cd8 56$bad = 0;
79072805
LW
57$good = 0;
58$total = @ARGV;
8d063cd8 59while ($test = shift) {
fe14fcc3 60 if ($test =~ /^$/) {
378cc40b
LW
61 next;
62 }
fe14fcc3
LW
63 $te = $test;
64 chop($te);
55497cff 65 print "$te" . '.' x (18 - length($te));
135863df 66 if ($sharpbang) {
e77eedc2 67 open(results,"./$test |") || (print "can't run.\n");
135863df 68 } else {
e77eedc2
NIS
69 open(script,"$test") || die "Can't run $test.\n";
70 $_ = <script>;
71 close(script);
135863df
AB
72 if (/#!..perl(.*)/) {
73 $switch = $1;
55497cff
PP
74 if ($^O eq 'VMS') {
75 # Must protect uppercase switches with "" on command line
76 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
77 }
135863df
AB
78 } else {
79 $switch = '';
80 }
e77eedc2 81 open(results,"perl$switch $test |") || (print "can't run.\n");
135863df 82 }
8d063cd8 83 $ok = 0;
378cc40b 84 $next = 0;
e77eedc2
NIS
85 while (<results>) {
86 if (/^$/) { next;};
8d063cd8
LW
87 if ($verbose) {
88 print $_;
89 }
90 unless (/^#/) {
91 if (/^1\.\.([0-9]+)/) {
92 $max = $1;
2b317908
LW
93 $totmax += $max;
94 $files += 1;
8d063cd8
LW
95 $next = 1;
96 $ok = 1;
97 } else {
7e1cf235 98 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
8d063cd8
LW
99 if (/^ok (.*)/ && $1 == $next) {
100 $next = $next + 1;
101 } else {
102 $ok = 0;
103 }
104 }
105 }
106 }
107 $next = $next - 1;
108 if ($ok && $next == $max) {
bcce72a7
PP
109 if ($max) {
110 print "ok\n";
111 $good = $good + 1;
112 } else {
113 print "skipping test on this platform\n";
114 $files -= 1;
115 }
8d063cd8
LW
116 } else {
117 $next += 1;
e77eedc2 118 print "FAILED on test $next\n";
8d063cd8
LW
119 $bad = $bad + 1;
120 $_ = $test;
121 if (/^base/) {
378cc40b 122 die "Failed a basic test--cannot continue.\n";
8d063cd8
LW
123 }
124 }
125}
126
127if ($bad == 0) {
128 if ($ok) {
129 print "All tests successful.\n";
130 } else {
378cc40b 131 die "FAILED--no tests were run for some reason.\n";
8d063cd8
LW
132 }
133} else {
79072805 134 $pct = sprintf("%.2f", $good / $total * 100);
8d063cd8 135 if ($bad == 1) {
f46c10df 136 warn "Failed 1 test script out of $total, $pct% okay.\n";
8d063cd8 137 } else {
f46c10df 138 warn "Failed $bad test scripts out of $total, $pct% okay.\n";
8d063cd8 139 }
f46c10df
CS
140 warn <<'SHRDLU';
141 ### Since not all tests were successful, you may want to run some
142 ### of them individually and examine any diagnostic messages they
143 ### produce. See the INSTALL document's section on "make test".
144SHRDLU
8d063cd8
LW
145}
146($user,$sys,$cuser,$csys) = times;
f46c10df 147print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
2b317908 148 $user,$sys,$cuser,$csys,$files,$totmax);
e77eedc2 149exit $bad != 0;