Pod style
[p5sagit/p5-mst-13.2.git] / win32 / TEST
1 #!./perl
2
3 # Last change: Fri Jan 10 09:57:03 WET 1997
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
8 $| = 1;
9
10 if ($ARGV[0] eq '-v') {
11     $verbose = 1;
12     shift;
13 }
14
15 chdir 't' if -f 't/TEST';
16
17 die "You need to run \"make test\" first to set things up.\n" 
18   unless -e 'perl' or -e 'perl.exe';
19
20 $ENV{EMXSHELL} = 'sh';        # For OS/2
21
22 if ($ARGV[0] eq '') {
23     push( @ARGV, `dir/s/b base` );
24     push( @ARGV, `dir/s/b comp` );
25     push( @ARGV, `dir/s/b cmd` );
26     push( @ARGV, `dir/s/b io` );
27     push( @ARGV, `dir/s/b op` );
28     push( @ARGV, `dir/s/b pragma` );
29     push( @ARGV, `dir/s/b lib` );
30
31     grep( chomp, @ARGV );
32     @ARGV = grep( /\.t$/, @ARGV );
33     grep( s/.*t\\//, @ARGV );
34 #    @ARGV = split(/[ \n]/,
35 #      `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`);
36 }
37
38 if ($^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'qnx' || 1) {
39     $sharpbang = 0;
40 }
41 else {
42     open(CONFIG, "../config.sh");
43     while (<CONFIG>) {
44         if (/sharpbang='(.*)'/) {
45             $sharpbang = ($1 eq '#!');
46             last;
47         }
48     }
49     close(CONFIG);
50 }
51
52 $bad = 0;
53 $good = 0;
54 $total = @ARGV;
55 while ($test = shift) {
56     if ($test =~ /^$/) {
57         next;
58     }
59     $te = $test;
60     chop($te);
61     print "$te" . '.' x (18 - length($te));
62     if ($sharpbang) {
63         open(results,"./$test |") || (print "can't run.\n");
64     } else {
65         open(script,"$test") || die "Can't run $test.\n";
66         $_ = <script>;
67         close(script);
68         if (/#!..perl(.*)/) {
69             $switch = $1;
70             if ($^O eq 'VMS') {
71                 # Must protect uppercase switches with "" on command line
72                 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
73             }
74         } else {
75             $switch = '';
76         }
77         open(results,"perl$switch $test |") || (print "can't run.\n");
78     }
79     $ok = 0;
80     $next = 0;
81     while (<results>) {
82         if (/^$/) { next;};
83         if ($verbose) {
84             print $_;
85         }
86         unless (/^#/) {
87             if (/^1\.\.([0-9]+)/) {
88                 $max = $1;
89                 $totmax += $max;
90                 $files += 1;
91                 $next = 1;
92                 $ok = 1;
93             } else {
94                 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
95                 if (/^ok (.*)/ && $1 == $next) {
96                     $next = $next + 1;
97                 } else {
98                     $ok = 0;
99                 }
100             }
101         }
102     }
103     $next = $next - 1;
104     if ($ok && $next == $max) {
105         if ($max) {
106             print "ok\n";
107             $good = $good + 1;
108         } else {
109             print "skipping test on this platform\n";
110             $files -= 1;
111         }
112     } else {
113         $next += 1;
114         print "FAILED on test $next\n";
115         $bad = $bad + 1;
116         $_ = $test;
117         if (/^base/) {
118             die "Failed a basic test--cannot continue.\n";
119         }
120     }
121 }
122
123 if ($bad == 0) {
124     if ($ok) {
125         print "All tests successful.\n";
126     } else {
127         die "FAILED--no tests were run for some reason.\n";
128     }
129 } else {
130     $pct = sprintf("%.2f", $good / $total * 100);
131     if ($bad == 1) {
132         warn "Failed 1 test script out of $total, $pct% okay.\n";
133     } else {
134         warn "Failed $bad test scripts out of $total, $pct% okay.\n";
135     }
136        warn <<'SHRDLU';
137    ### Since not all tests were successful, you may want to run some
138    ### of them individually and examine any diagnostic messages they
139    ### produce.  See the INSTALL document's section on "make test".
140 SHRDLU
141 }
142 ($user,$sys,$cuser,$csys) = times;
143 print sprintf("u=%g  s=%g  cu=%g  cs=%g  scripts=%d  tests=%d\n",
144     $user,$sys,$cuser,$csys,$files,$totmax);
145 exit $bad != 0;