perl 5.003_01: vms/genconfig.pl
[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@genetics.upenn.edu
5 $
6 $!  A little basic setup
7 $   On Error Then Goto wrapup
8 $   olddef = F$Environment("Default")
9 $   If F$Search("t.dir").nes.""
10 $   Then
11 $       Set Default [.t]
12 $   Else
13 $       If F$TrnLNm("Perl_Root").nes.""
14 $       Then 
15 $           Set Default Perl_Root:[t]
16 $       Else
17 $           Write Sys$Error "Can't find test directory"
18 $           Exit 44
19 $       EndIf
20 $   EndIf
21 $
22 $!  Pick up a copy of perl to use for the tests
23 $   Delete/Log/NoConfirm Perl.;*
24 $   Copy/Log/NoConfirm [-]Perl.Exe []Perl.
25 $
26 $!  Make the environment look a little friendlier to tests which assume Unix
27 $   cat = "Type"
28 $   Macro/NoDebug/Object=Echo.Obj Sys$Input
29                 .title echo
30                 .psect data,wrt,noexe
31         dsc:
32                 .word 0
33                 .byte 14 ; DSC$K_DTYPE_T
34                 .byte 2  ; DSC$K_CLASS_D
35                 .long 0
36                 .psect code,nowrt,exe
37                 .entry  echo,^m<r2,r3>
38                 movab   dsc,r2
39                 pushab  (r2)
40                 calls   #1,G^LIB$GET_FOREIGN
41                 movl    4(r2),r3
42                 movzwl  (r2),r0
43                 addl2   4(r2),r0
44                 cmpl    r3,r0
45                 bgtru   sym.3
46                 nop     
47         sym.1:
48                 movb    (r3),r0
49                 cmpb    r0,#65
50                 blss    sym.2
51                 cmpb    r0,#90
52                 bgtr    sym.2
53                 cvtbl   r0,r0
54                 addl2   #32,r0
55                 cvtlb   r0,(r3)
56         sym.2:
57                 incl    r3
58                 movzwl  (r2),r0
59                 addl2   4(r2),r0
60                 cmpl    r3,r0
61                 blequ   sym.1
62         sym.3:
63                 pushab  (r2)
64                 calls   #1,G^LIB$PUT_OUTPUT
65                 movl    #1,r0
66                 ret     
67                 .end echo
68 $   Link/NoTrace Echo.Obj;
69 $   Delete/Log/NoConfirm Echo.Obj;*
70 $   echo = "$" + F$Parse("Echo.Exe")
71 $
72 $!  And do it
73 $   testdir = "Directory/NoHead/NoTrail/Column=1"
74 $   Define/User Perlshr Sys$Disk:[-]PerlShr.Exe
75 $   MCR Sys$Disk:[]Perl. "''p1'" "''p2'" "''p3'" "''p4'" "''p5'" "''p6'"
76 $   Deck/Dollar=$$END-OF-TEST$$
77 # $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
78 # Modified for VMS 30-Sep-1994  Charles Bailey  bailey@genetics.upenn.edu
79 #
80 # This is written in a peculiar style, since we're trying to avoid
81 # most of the constructs we'll be testing for.
82
83 # skip those tests we know will fail entirely or cause perl to hang bacause
84 # of Unixisms
85 @compexcl=('cpp.t','script.t');
86 @ioexcl=('argv.t','dup.t','fs.t','inplace.t','pipe.t');
87 @libexcl=('anydbm.t','db-btree.t','db-hash.t','db-recno.t',
88           'gdbm.t','ndbm.t','odbm.t','sdbm.t','posix.t','soundex.t');
89 @opexcl=('exec.t','fork.t','glob.t','magic.t','misc.t','stat.t');
90 @exclist=(@compexcl,@ioexcl,@libexcl,@opexcl);
91 foreach $file (@exclist) { $skip{$file}++; }
92
93 $| = 1;
94
95 @ARGV = grep($_,@ARGV);  # remove empty elements due to "''p1'" syntax
96
97 if ($ARGV[0] eq '-v') {
98     $verbose = 1;
99     shift;
100 }
101
102 chdir 't' if -f 't/TEST';
103
104 if ($ARGV[0] eq '') {
105     foreach (<[.*]*.t>) {
106       s/.*[\[.]t./[./;
107       ($fname = $_) =~ s/.*\]//;
108       if ($skip{"\L$fname"}) { push(@skipped,$_); }
109       else { push(@ARGV,$_); }
110     }
111 }
112
113 if (@skipped) {
114   print "The following tests were skipped because they rely extensively on\n";
115   print " Unixisms not compatible with the current version of perl for VMS:\n";
116   print "\t",join("\n\t",@skipped),"\n\n";
117 }
118
119 $bad = 0;
120 $good = 0;
121 $total = @ARGV;
122 while ($test = shift) {
123     if ($test =~ /^$/) {
124         next;
125     }
126     $te = $test;
127     chop($te);
128     $te .= '.' x (24 - length($te));
129         open(script,"$test") || die "Can't run $test.\n";
130         $_ = <script>;
131         close(script);
132         if (/#!..perl(.*)/) {
133             $switch = $1;
134         } else {
135             $switch = '';
136         }
137         open(results,"\$ MCR Sys\$Disk:[]Perl. $switch $test |") || (print "can't run.\n");
138     $ok = 0;
139     $next = 0;
140     while (<results>) {
141         if ($verbose) {
142             print "$te$_";
143             $te = '';
144         }
145         unless (/^#/) {
146             if (/^1\.\.([0-9]+)/) {
147                 $max = $1;
148                 $totmax += $max;
149                 $files += 1;
150                 $next = 1;
151                 $ok = 1;
152             } else {
153                 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
154                 next if /^\s*$/; # our 'echo' substitute produces one more \n than Unix'
155                 if (/^ok (.*)/ && $1 == $next) {
156                     $next = $next + 1;
157                 } else {
158                     $ok = 0;
159                 }
160             }
161         }
162     }
163     $next = $next - 1;
164     if ($ok && $next == $max) {
165         print "${te}ok\n";
166         $good = $good + 1;
167     } else {
168         $next += 1;
169         print "${te}FAILED on test $next\n";
170         $bad = $bad + 1;
171         $_ = $test;
172         if (/^base/) {
173             die "Failed a basic test--cannot continue.\n";
174         }
175     }
176 }
177
178 if ($bad == 0) {
179     if ($ok) {
180         print "All tests successful.\n";
181     } else {
182         die "FAILED--no tests were run for some reason.\n";
183     }
184 } else {
185     $pct = sprintf("%.2f", $good / $total * 100);
186     if ($bad == 1) {
187         warn "Failed 1 test, $pct% okay.\n";
188     } else {
189         warn "Failed $bad/$total tests, $pct% okay.\n";
190     }
191 }
192 ($user,$sys,$cuser,$csys) = times;
193 print sprintf("u=%g  s=%g  cu=%g  cs=%g  files=%d  tests=%d\n",
194     $user,$sys,$cuser,$csys,$files,$totmax);
195 $$END-OF-TEST$$
196 $ wrapup:
197 $   If F$Search("Echo.Exe").nes."" Then Delete/Log/NoConfirm Echo.Exe;*
198 $   Set Default &olddef
199 $   Exit