arithmetic fix for skipped tests on VMS
[p5sagit/p5-mst-13.2.git] / vms / test.com
1 $!  Test.Com - DCL driver for perl5 regression tests
2 $!
3 $!  Version 1.1   4-Dec-1995
4 $!  Charles Bailey  bailey@newman.upenn.edu
5 $!
6 $!  A little basic setup
7 $   On Error Then Goto wrapup
8 $   olddef = F$Environment("Default")
9 $   oldmsg = F$Environment("Message")
10 $   If F$Search("t.dir").nes.""
11 $   Then
12 $       Set Default [.t]
13 $   Else
14 $       If F$TrnLNm("Perl_Root").nes.""
15 $       Then 
16 $           Set Default Perl_Root:[t]
17 $       Else
18 $           Write Sys$Error "Can't find test directory"
19 $           Exit 44
20 $       EndIf
21 $   EndIf
22 $   Set Message /NoFacility/NoSeverity/NoIdentification/NoText
23 $!
24 $   exe = ".Exe"
25 $   If p1.nes."" Then exe = p1
26 $   If F$Extract(0,1,exe) .nes. "."
27 $   Then
28 $     Write Sys$Error ""
29 $     Write Sys$Error "The first parameter passed to Test.Com must be the file type used for the"
30 $     Write Sys$Error "images produced when you built Perl (i.e. "".Exe"", unless you edited"
31 $     Write Sys$Error "Descrip.MMS or used the AXE=1 macro in the MM[SK] command line."
32 $     Write Sys$Error ""
33 $     Exit 44
34 $   EndIf
35 $!
36 $!  "debug" perl if second parameter is nonblank
37 $!
38 $   dbg = ""
39 $   ndbg = ""
40 $   if p2.nes."" then dbg  = "dbg"
41 $   if p2.nes."" then ndbg = "ndbg"
42 $!
43 $!  Pick up a copy of perl to use for the tests
44 $   If F$Search("Perl.").nes."" Then Delete/Log/NoConfirm Perl.;*
45 $   Copy/Log/NoConfirm [-]'ndbg'Perl'exe' []Perl.
46 $!
47 $!  Pick up a copy of vmspipe.com to use for the tests
48 $   If F$Search("VMSPIPE.COM").nes."" then Delete/Log/Noconfirm VMSPIPE.COM;*
49 $   Copy/Log/NoConfirm [-]VMSPIPE.COM []
50 $!
51 $!  Make the environment look a little friendlier to tests which assume Unix
52 $   cat == "Type"
53 $   Macro/NoDebug/NoList/Object=Echo.Obj Sys$Input
54                 .title echo
55                 .psect data,wrt,noexe
56         dsc:
57                 .word 0
58                 .byte 14 ; DSC$K_DTYPE_T
59                 .byte 2  ; DSC$K_CLASS_D
60                 .long 0
61                 .psect code,nowrt,exe
62                 .entry  echo,^m<r2,r3>
63                 movab   dsc,r2
64                 pushab  (r2)
65                 calls   #1,G^LIB$GET_FOREIGN
66                 movl    4(r2),r3
67                 movzwl  (r2),r0
68                 addl2   4(r2),r0
69                 cmpl    r3,r0
70                 bgtru   sym.3
71                 nop     
72         sym.1:
73                 movb    (r3),r0
74                 cmpb    r0,#65
75                 blss    sym.2
76                 cmpb    r0,#90
77                 bgtr    sym.2
78                 cvtbl   r0,r0
79                 addl2   #32,r0
80                 cvtlb   r0,(r3)
81         sym.2:
82                 incl    r3
83                 movzwl  (r2),r0
84                 addl2   4(r2),r0
85                 cmpl    r3,r0
86                 blequ   sym.1
87         sym.3:
88                 pushab  (r2)
89                 calls   #1,G^LIB$PUT_OUTPUT
90                 movl    #1,r0
91                 ret     
92                 .end echo
93 $   If F$Search("Echo.Exe").nes."" Then Delete/Log/NoConfirm Echo.Exe;*
94 $   Link/NoMap/NoTrace/Exe=Echo.Exe Echo.Obj;
95 $   Delete/Log/NoConfirm Echo.Obj;*
96 $   echo == "$" + F$Parse("Echo.Exe")
97 $!
98 $!  And do it
99 $   Show Process/Accounting
100 $   testdir = "Directory/NoHead/NoTrail/Column=1"
101 $   PerlShr_filespec = f$parse("Sys$Disk:[-]''dbg'PerlShr''exe'")
102 $   Define 'dbg'Perlshr 'PerlShr_filespec'
103 $   MCR Sys$Disk:[]Perl. "-I[-.lib]" - "''p3'" "''p4'" "''p5'" "''p6'"
104 $   Deck/Dollar=$$END-OF-TEST$$
105 # $RCSfile: test.com,v $$Revision: 1.1 $$Date: 2001/11/13 00:26:19 $
106 # Modified for VMS 30-Sep-1994  Charles Bailey  bailey@newman.upenn.edu
107 #
108 # This is written in a peculiar style, since we're trying to avoid
109 # most of the constructs we'll be testing for.
110
111 # skip those tests we know will fail entirely or cause perl to hang bacause
112 # of Unixisms in the tests.  (The Perl operators being tested may work fine,
113 # but the tests may use other operators which don't.)
114 use Config;
115 use File::Spec;
116
117 @compexcl=('cpp.t');
118 @opexcl=('die_exit.t','exec.t','stat.t');
119 @exclist=(@compexcl,@libexcl,@opexcl);
120 foreach $file (@exclist) { $skip{$file}++; }
121
122 $| = 1;
123
124 # Let tests know they're running in the perl core.  Useful for modules
125 # which live dual lives on CPAN.
126 $ENV{PERL_CORE} = 1;
127
128 @ARGV = grep($_,@ARGV);  # remove empty elements due to "''p1'" syntax
129
130 if (lc($ARGV[0]) eq '-v') {
131     $verbose = 1;
132     shift;
133 }
134
135 chdir 't' if -f 't/TEST';
136
137 if ($ARGV[0] eq '') {
138     foreach (<[.*]*.t>, <[-.ext...]*.t>, <[-.lib...]*.t>) {
139       $_ = File::Spec->abs2rel($_);
140       s/\[([a-z]+)/[.$1/;      # hmm, abs2rel doesn't do subdirs of the cwd
141       ($fname = $_) =~ s/.*\]//;
142       if ($skip{"\L$fname"}) { push(@skipped,$_); }
143       else { push(@ARGV,$_); }
144     }
145 }
146
147 if (@skipped) {
148   print "The following tests were skipped because they rely extensively on\n";
149   print " Unixisms not compatible with the current version of perl for VMS:\n";
150   print "\t",join("\n\t",@skipped),"\n\n";
151 }
152
153 $bad = 0;
154 $good = 0;
155 $extra_skip = 0;
156 $total = @ARGV;
157 while ($test = shift) {
158     if ($test =~ /^$/) {
159         next;
160     }
161     $te = $test;
162     chop($te);
163     $te .= '.' x (40 - length($te));
164         open(script,"$test") || die "Can't run $test.\n";
165         $_ = <script>;
166         close(script);
167         if (/#!..perl(.*)/) {
168             $switch = $1;
169             # Add "" to protect uppercase switches on command line
170             $switch =~ s/-(\S*[A-Z]\S*)/"-$1"/g;
171         } else {
172             $switch = '';
173         }
174         open(results,"\$ MCR Sys\$Disk:[]Perl. \"-I[-.lib]\" $switch $test 2>&1|") || (print "can't run.\n");
175     $ok = 0;
176     $next = 0;
177     $pending_not = 0;
178     while (<results>) {
179         if ($verbose) {
180             print "$te$_";
181             $te = '';
182         }
183         unless (/^#/) {
184             if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) {
185                 $max = $1;
186                 %todo = map { $_ => 1 } split / /, $3 if $3;
187                 $totmax += $max;
188                 $files += 1;
189                 $next = 1;
190                 $ok = 1;
191             } else {
192                 # our 'echo' substitute produces one more \n than Unix'
193                 next if /^\s*$/;
194
195
196                 if (/^(not )?ok (\d+)[^#]*(\s*#.*)?/ &&
197                     $2 == $next)
198                 {
199                     my($not, $num, $extra) = ($1, $2, $3);
200                     my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
201                     $istodo = 1 if $todo{$num};
202
203                     if( $not && !$istodo ) {
204                         $ok = 0;
205                         $next = $num;
206                         last;
207                     }
208                     elsif( $pending_not ) {
209                         $next = $num;
210                         $ok = 0;
211                     }
212                     else {
213                         $next = $next + 1;
214                     }
215                 }
216                 elsif(/^not $/) {
217                     # VMS has this problem.  It sometimes adds newlines
218                     # between prints.  This sometimes means you get
219                     # "not \nok 42"
220                     $pending_not = 1;
221                 }
222                 elsif (/^Bail out!\s*(.*)/i) { # magic words
223                     die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
224                 }
225                 else {
226                     $ok = 0;
227                 }
228
229             }
230         }
231     }
232     $next = $next - 1;
233     if ($ok && $next == $max) {
234         if ($max) {
235             print "${te}ok\n";
236             $good = $good + 1;
237         } else {
238             print "${te}skipping test on this platform\n";
239             $files -= 1;
240             $extra_skip = $extra_skip + 1;
241         }
242     } else {
243         $next += 1;
244         print "${te}FAILED on test $next\n";
245         $bad = $bad + 1;
246         $_ = $test;
247         if (/^base/) {
248             die "Failed a basic test--cannot continue.\n";
249         }
250     }
251 }
252
253 if ($bad == 0) {
254     if ($ok) {
255         print "All tests successful.\n";
256     } else {
257         die "FAILED--no tests were run for some reason.\n";
258     }
259 } else {
260     # $pct = sprintf("%.2f", $good / $total * 100);
261     $gtotal = $total - $extra_skip;
262     if ($gtotal <= 0) { $gtotal = $total; }
263     $pct = sprintf("%.2f", $good / $gtotal * 100);
264     if ($bad == 1) {
265         warn "Failed 1 test, $pct% okay.\n";
266    } else {
267          if ($extra_skip > 0) {
268              warn "Total tests: $total, Passed $good, Skipped $extra_skip.\n";
269              warn "Failed $bad/$gtotal tests, $pct% okay.\n";
270          }
271          else {
272              warn "Total tests: $total, Passed $good.\n";
273              warn "Failed $bad/$gtotal tests, $pct% okay.\n";
274          }
275     }
276 }
277 ($user,$sys,$cuser,$csys) = times;
278 print sprintf("u=%g  s=%g  cu=%g  cs=%g  scripts=%d  tests=%d\n",
279     $user,$sys,$cuser,$csys,$files,$totmax);
280 $$END-OF-TEST$$
281 $ wrapup:
282 $   deassign 'dbg'Perlshr
283 $   Show Process/Accounting
284 $   Set Default &olddef
285 $   Set Message 'oldmsg'
286 $   Exit