Commit | Line | Data |
---|---|---|
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 | ||
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]/, | |
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 | ||
46 | $bad = 0; | |
47 | $good = 0; | |
48 | $total = @tests; | |
49 | $files = 0; | |
50 | $totmax = 0; | |
088b5126 GS |
51 | $maxlen = 0; |
52 | foreach (@tests) { | |
53 | $len = length; | |
54 | $maxlen = $len if $len > $maxlen; | |
55 | } | |
56 | # +3 : we want three dots between the test name and the "ok" | |
57 | # -2 : the .t suffix | |
58 | $dotdotdot = $maxlen + 3 - 2; | |
bb365837 GS |
59 | while ($test = shift @tests) { |
60 | ||
61 | if ( $infinite{$test} && $type eq 'compile' ) { | |
62 | print STDERR "$test creates infinite loop! Skipping.\n"; | |
63 | next; | |
6ee623d5 | 64 | } |
bb365837 GS |
65 | if ($test =~ /^$/) { |
66 | next; | |
6ee623d5 | 67 | } |
bb365837 GS |
68 | $te = $test; |
69 | chop($te); | |
088b5126 | 70 | print "$te" . '.' x ($dotdotdot - length($te)); |
bb365837 | 71 | |
d638aca2 GS |
72 | open(SCRIPT,"<$test") or die "Can't run $test.\n"; |
73 | $_ = <SCRIPT>; | |
74 | close(SCRIPT); | |
75 | if (/#!.*perl(.*)$/) { | |
76 | $switch = $1; | |
77 | if ($^O eq 'VMS') { | |
78 | # Must protect uppercase switches with "" on command line | |
79 | $switch =~ s/-([A-Z]\S*)/"-$1"/g; | |
55497cff | 80 | } |
135863df | 81 | } |
bb365837 | 82 | else { |
d638aca2 GS |
83 | $switch = ''; |
84 | } | |
6ee623d5 | 85 | |
d638aca2 GS |
86 | if ($type eq 'perl') { |
87 | open(RESULTS,"./perl$switch $test |") or print "can't run.\n"; | |
88 | } | |
89 | else { | |
90 | open(RESULTS, "./perl -I../lib ../utils/perlcc ./$test " | |
91 | ."-run -verbose dcf -log ../compilelog |") | |
92 | or print "can't compile.\n"; | |
6ee623d5 | 93 | } |
d638aca2 | 94 | |
bb365837 GS |
95 | $ok = 0; |
96 | $next = 0; | |
97 | while (<RESULTS>) { | |
98 | if ($verbose) { | |
99 | print $_; | |
100 | } | |
101 | unless (/^#/) { | |
102 | if (/^1\.\.([0-9]+)/) { | |
103 | $max = $1; | |
104 | $totmax += $max; | |
105 | $files += 1; | |
106 | $next = 1; | |
107 | $ok = 1; | |
108 | } | |
109 | else { | |
110 | $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; | |
111 | if (/^ok (\d+)(\s*#.*)?$/ && $1 == $next) { | |
112 | $next = $next + 1; | |
113 | } | |
114 | else { | |
115 | $ok = 0; | |
116 | } | |
8d063cd8 LW |
117 | } |
118 | } | |
119 | } | |
bb365837 GS |
120 | close RESULTS; |
121 | $next = $next - 1; | |
122 | if ($ok && $next == $max) { | |
123 | if ($max) { | |
124 | print "ok\n"; | |
125 | $good = $good + 1; | |
126 | } | |
127 | else { | |
128 | print "skipping test on this platform\n"; | |
129 | $files -= 1; | |
130 | } | |
bcce72a7 | 131 | } |
bb365837 GS |
132 | else { |
133 | $next += 1; | |
134 | print "FAILED at test $next\n"; | |
135 | $bad = $bad + 1; | |
136 | $_ = $test; | |
137 | if (/^base/) { | |
138 | die "Failed a basic test--cannot continue.\n"; | |
139 | } | |
8d063cd8 LW |
140 | } |
141 | } | |
8d063cd8 | 142 | |
bb365837 GS |
143 | if ($bad == 0) { |
144 | if ($ok) { | |
145 | print "All tests successful.\n"; | |
146 | # XXX add mention of 'perlbug -ok' ? | |
147 | } | |
148 | else { | |
149 | die "FAILED--no tests were run for some reason.\n"; | |
150 | } | |
8d063cd8 | 151 | } |
bb365837 GS |
152 | else { |
153 | $pct = sprintf("%.2f", $good / $total * 100); | |
154 | if ($bad == 1) { | |
155 | warn "Failed 1 test script out of $total, $pct% okay.\n"; | |
156 | } | |
157 | else { | |
158 | warn "Failed $bad test scripts out of $total, $pct% okay.\n"; | |
159 | } | |
160 | warn <<'SHRDLU'; | |
f46c10df CS |
161 | ### Since not all tests were successful, you may want to run some |
162 | ### of them individually and examine any diagnostic messages they | |
163 | ### produce. See the INSTALL document's section on "make test". | |
6ee623d5 GS |
164 | ### If you are testing the compiler, then ignore this message |
165 | ### and run | |
166 | ### ./perl harness | |
167 | ### in the directory ./t. | |
f46c10df | 168 | SHRDLU |
bb365837 | 169 | warn <<'SHRDLU' if $good / $total > 0.8; |
3e6e8be7 MB |
170 | ### |
171 | ### Since most tests were successful, you have a good chance to | |
172 | ### get information with better granularity by running | |
6ee623d5 | 173 | ### ./perl harness |
3e6e8be7 MB |
174 | ### in directory ./t. |
175 | SHRDLU | |
bb365837 GS |
176 | } |
177 | ($user,$sys,$cuser,$csys) = times; | |
178 | print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n", | |
179 | $user,$sys,$cuser,$csys,$files,$totmax); | |
6ee623d5 | 180 | } |
3e6e8be7 | 181 | exit ($bad != 0); |