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