Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | #!./perl |
2 | ||
e824fb2c | 3 | # Last change: Fri May 28 03:16:57 BST 1999 |
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 | ||
3e6e8be7 | 10 | if ($#ARGV >= 0 && $ARGV[0] eq '-v') { |
8d063cd8 LW |
11 | $verbose = 1; |
12 | shift; | |
13 | } | |
14 | ||
378cc40b LW |
15 | chdir 't' if -f 't/TEST'; |
16 | ||
3e6e8be7 | 17 | die "You need to run \"make test\" first to set things up.\n" |
4633a7c4 LW |
18 | unless -e 'perl' or -e 'perl.exe'; |
19 | ||
3fb91a5e GS |
20 | # check leakage for embedders |
21 | $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL}; | |
22 | ||
4633a7c4 | 23 | $ENV{EMXSHELL} = 'sh'; # For OS/2 |
748a9306 | 24 | |
3e6e8be7 MB |
25 | if ($#ARGV == -1) { |
26 | @ARGV = split(/[ \n]/, | |
04c8f6e4 | 27 | `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`); |
8d063cd8 LW |
28 | } |
29 | ||
6ee623d5 GS |
30 | %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 ); |
31 | ||
32 | _testprogs('perl', @ARGV); | |
33 | _testprogs('compile', @ARGV) if (-e "../testcompile"); | |
34 | ||
bb365837 GS |
35 | sub _testprogs { |
36 | $type = shift @_; | |
37 | @tests = @_; | |
6ee623d5 GS |
38 | |
39 | ||
bb365837 | 40 | print <<'EOT' if ($type eq 'compile'); |
6ee623d5 GS |
41 | -------------------------------------------------------------------------------- |
42 | TESTING COMPILER | |
43 | -------------------------------------------------------------------------------- | |
bb365837 GS |
44 | EOT |
45 | ||
9636a016 GS |
46 | $ENV{PERLCC_TIMEOUT} = 120 |
47 | if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT}); | |
ef712cf7 | 48 | |
bb365837 GS |
49 | $bad = 0; |
50 | $good = 0; | |
51 | $total = @tests; | |
52 | $files = 0; | |
53 | $totmax = 0; | |
088b5126 GS |
54 | $maxlen = 0; |
55 | foreach (@tests) { | |
56 | $len = length; | |
57 | $maxlen = $len if $len > $maxlen; | |
58 | } | |
59 | # +3 : we want three dots between the test name and the "ok" | |
60 | # -2 : the .t suffix | |
61 | $dotdotdot = $maxlen + 3 - 2; | |
bb365837 GS |
62 | while ($test = shift @tests) { |
63 | ||
64 | if ( $infinite{$test} && $type eq 'compile' ) { | |
65 | print STDERR "$test creates infinite loop! Skipping.\n"; | |
66 | next; | |
6ee623d5 | 67 | } |
bb365837 GS |
68 | if ($test =~ /^$/) { |
69 | next; | |
6ee623d5 | 70 | } |
bb365837 GS |
71 | $te = $test; |
72 | chop($te); | |
088b5126 | 73 | print "$te" . '.' x ($dotdotdot - length($te)); |
bb365837 | 74 | |
d638aca2 GS |
75 | open(SCRIPT,"<$test") or die "Can't run $test.\n"; |
76 | $_ = <SCRIPT>; | |
77 | close(SCRIPT); | |
78 | if (/#!.*perl(.*)$/) { | |
79 | $switch = $1; | |
80 | if ($^O eq 'VMS') { | |
81 | # Must protect uppercase switches with "" on command line | |
82 | $switch =~ s/-([A-Z]\S*)/"-$1"/g; | |
55497cff | 83 | } |
135863df | 84 | } |
bb365837 | 85 | else { |
d638aca2 GS |
86 | $switch = ''; |
87 | } | |
6ee623d5 | 88 | |
d638aca2 | 89 | if ($type eq 'perl') { |
be24517c JH |
90 | my $run = "./perl$switch $test |"; |
91 | open(RESULTS,$run) or print "can't run '$run': $!.\n"; | |
d638aca2 GS |
92 | } |
93 | else { | |
be24517c JH |
94 | my $compile = |
95 | "./perl -I../lib ../utils/perlcc -o ./$test.plc ./$test " | |
96 | ." && ./$test.plc |"; | |
97 | open(RESULTS, $compile) | |
98 | or print "can't compile '$compile': $!.\n"; | |
99 | unlink "./$test.plc"; | |
6ee623d5 | 100 | } |
d638aca2 | 101 | |
bb365837 GS |
102 | $ok = 0; |
103 | $next = 0; | |
104 | while (<RESULTS>) { | |
105 | if ($verbose) { | |
106 | print $_; | |
107 | } | |
108 | unless (/^#/) { | |
109 | if (/^1\.\.([0-9]+)/) { | |
110 | $max = $1; | |
111 | $totmax += $max; | |
112 | $files += 1; | |
113 | $next = 1; | |
114 | $ok = 1; | |
115 | } | |
116 | else { | |
117 | $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; | |
f178911d | 118 | if (/^ok (\d+)(\s*#.*)?/ && $1 == $next) { |
bb365837 | 119 | $next = $next + 1; |
d667a7e6 A |
120 | } |
121 | elsif (/^Bail out!\s*(.*)/i) { # magic words | |
122 | die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n"); | |
bb365837 GS |
123 | } |
124 | else { | |
125 | $ok = 0; | |
126 | } | |
8d063cd8 LW |
127 | } |
128 | } | |
129 | } | |
bb365837 GS |
130 | close RESULTS; |
131 | $next = $next - 1; | |
132 | if ($ok && $next == $max) { | |
133 | if ($max) { | |
134 | print "ok\n"; | |
135 | $good = $good + 1; | |
136 | } | |
137 | else { | |
138 | print "skipping test on this platform\n"; | |
139 | $files -= 1; | |
140 | } | |
bcce72a7 | 141 | } |
bb365837 GS |
142 | else { |
143 | $next += 1; | |
144 | print "FAILED at test $next\n"; | |
145 | $bad = $bad + 1; | |
146 | $_ = $test; | |
147 | if (/^base/) { | |
148 | die "Failed a basic test--cannot continue.\n"; | |
149 | } | |
8d063cd8 LW |
150 | } |
151 | } | |
8d063cd8 | 152 | |
bb365837 GS |
153 | if ($bad == 0) { |
154 | if ($ok) { | |
155 | print "All tests successful.\n"; | |
156 | # XXX add mention of 'perlbug -ok' ? | |
157 | } | |
158 | else { | |
159 | die "FAILED--no tests were run for some reason.\n"; | |
160 | } | |
8d063cd8 | 161 | } |
bb365837 | 162 | else { |
ba1398cf | 163 | $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00"; |
bb365837 | 164 | if ($bad == 1) { |
e824fb2c | 165 | warn "Failed 1 test script out of $files, $pct% okay.\n"; |
bb365837 GS |
166 | } |
167 | else { | |
e824fb2c | 168 | warn "Failed $bad test scripts out of $files, $pct% okay.\n"; |
bb365837 GS |
169 | } |
170 | warn <<'SHRDLU'; | |
f46c10df CS |
171 | ### Since not all tests were successful, you may want to run some |
172 | ### of them individually and examine any diagnostic messages they | |
173 | ### produce. See the INSTALL document's section on "make test". | |
6ee623d5 GS |
174 | ### If you are testing the compiler, then ignore this message |
175 | ### and run | |
176 | ### ./perl harness | |
177 | ### in the directory ./t. | |
f46c10df | 178 | SHRDLU |
bb365837 | 179 | warn <<'SHRDLU' if $good / $total > 0.8; |
3e6e8be7 MB |
180 | ### |
181 | ### Since most tests were successful, you have a good chance to | |
182 | ### get information with better granularity by running | |
6ee623d5 | 183 | ### ./perl harness |
3e6e8be7 MB |
184 | ### in directory ./t. |
185 | SHRDLU | |
bb365837 GS |
186 | } |
187 | ($user,$sys,$cuser,$csys) = times; | |
188 | print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n", | |
189 | $user,$sys,$cuser,$csys,$files,$totmax); | |
6ee623d5 | 190 | } |
3e6e8be7 | 191 | exit ($bad != 0); |