source: trunk/third/perl/win32/TEST @ 10724

Revision 10724, 3.2 KB checked in by ghudson, 27 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r10723, which included commits to RCS files with non-trunk default branches.
Line 
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
10if ($ARGV[0] eq '-v') {
11    $verbose = 1;
12    shift;
13}
14
15chdir 't' if -f 't/TEST';
16
17die "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
22if ($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} else {
37
38@ARGV = map(glob($_),@ARGV);
39
40}
41
42if ($^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'qnx' || 1) {
43    $sharpbang = 0;
44}
45else {
46    open(CONFIG, "../config.sh");
47    while (<CONFIG>) {
48        if (/sharpbang='(.*)'/) {
49            $sharpbang = ($1 eq '#!');
50            last;
51        }
52    }
53    close(CONFIG);
54}
55
56$bad = 0;
57$good = 0;
58$total = @ARGV;
59while ($test = shift) {
60    if ($test =~ /^$/) {
61        next;
62    }
63    $te = $test;
64    chop($te);
65    print "$te" . '.' x (18 - length($te));
66    if ($sharpbang) {
67        open(results,"./$test |") || (print "can't run.\n");
68    } else {
69        open(script,"$test") || die "Can't run $test.\n";
70        $_ = <script>;
71        close(script);
72        if (/#!..perl(.*)/) {
73            $switch = $1;
74            if ($^O eq 'VMS') {
75                # Must protect uppercase switches with "" on command line
76                $switch =~ s/-([A-Z]\S*)/"-$1"/g;
77            }
78        } else {
79            $switch = '';
80        }
81        open(results,"perl$switch $test |") || (print "can't run.\n");
82    }
83    $ok = 0;
84    $next = 0;
85    while (<results>) {
86        if (/^$/) { next;};
87        if ($verbose) {
88            print $_;
89        }
90        unless (/^#/) {
91            if (/^1\.\.([0-9]+)/) {
92                $max = $1;
93                $totmax += $max;
94                $files += 1;
95                $next = 1;
96                $ok = 1;
97            } else {
98                $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
99                if (/^ok (.*)/ && $1 == $next) {
100                    $next = $next + 1;
101                } else {
102                    $ok = 0;
103                }
104            }
105        }
106    }
107    $next = $next - 1;
108    if ($ok && $next == $max) {
109        if ($max) {
110            print "ok\n";
111            $good = $good + 1;
112        } else {
113            print "skipping test on this platform\n";
114            $files -= 1;
115        }
116    } else {
117        $next += 1;
118        print "FAILED on test $next\n";
119        $bad = $bad + 1;
120        $_ = $test;
121        if (/^base/) {
122            die "Failed a basic test--cannot continue.\n";
123        }
124    }
125}
126
127if ($bad == 0) {
128    if ($ok) {
129        print "All tests successful.\n";
130    } else {
131        die "FAILED--no tests were run for some reason.\n";
132    }
133} else {
134    $pct = sprintf("%.2f", $good / $total * 100);
135    if ($bad == 1) {
136        warn "Failed 1 test script out of $total, $pct% okay.\n";
137    } else {
138        warn "Failed $bad test scripts out of $total, $pct% okay.\n";
139    }
140       warn <<'SHRDLU';
141   ### Since not all tests were successful, you may want to run some
142   ### of them individually and examine any diagnostic messages they
143   ### produce.  See the INSTALL document's section on "make test".
144SHRDLU
145}
146($user,$sys,$cuser,$csys) = times;
147print sprintf("u=%g  s=%g  cu=%g  cs=%g  scripts=%d  tests=%d\n",
148    $user,$sys,$cuser,$csys,$files,$totmax);
149exit $bad != 0;
Note: See TracBrowser for help on using the repository browser.