This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 9
[perl5.git] / try
CommitLineData
79072805
LW
1#!./perl -Dxstp
2
3# This is written in a peculiar style, since we're trying to avoid
4# most of the constructs we'll be testing for.
5
6$| = 1;
7
8if ($ARGV[0] eq '-v') {
9 $verbose = 1;
10 shift;
11}
12
13chdir 't' if -f 't/TEST';
14
15if ($ARGV[0] eq '') {
16 @ARGV = split(/[ \n]/,
17 `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
18}
19
20open(CONFIG,"../foo.sh");
21while (<CONFIG>) {
22 if (/sharpbang='(.*)'/) {
23 $sharpbang = ($1 eq '#!');
24 last;
25 }
26}
27$bad = 0;
28while ($test = shift) {
29 if ($test =~ /^$/) {
30 next;
31 }
32 $te = $test;
33 chop($te);
34 print "$te" . '.' x (15 - length($te));
35 if ($sharpbang) {
36 open(results,"./$test|") || (print "can't run.\n");
37 } else {
38 open(script,"$test") || die "Can't run $test.\n";
39 $_ = <script>;
40 close(script);
41 if (/#!..perl(.*)/) {
42 $switch = $1;
43 } else {
44 $switch = '';
45 }
46 open(results,"./perl$switch $test|") || (print "can't run.\n");
47 }
48 $ok = 0;
49 $next = 0;
50 while (<results>) {
51 if ($verbose) {
52 print $_;
53 }
54 unless (/^#/) {
55 if (/^1\.\.([0-9]+)/) {
56 $max = $1;
57 $totmax += $max;
58 $files += 1;
59 $next = 1;
60 $ok = 1;
61 } else {
62 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
63 if (/^ok (.*)/ && $1 == $next) {
64 $next = $next + 1;
65 } else {
66 $ok = 0;
67 }
68 }
69 }
70 }
71 $next = $next - 1;
72 if ($ok && $next == $max) {
73 print "ok\n";
74 } else {
75 $next += 1;
76 print "FAILED on test $next\n";
77 $bad = $bad + 1;
78 $_ = $test;
79 if (/^base/) {
80 die "Failed a basic test--cannot continue.\n";
81 }
82 }
83}
84
85if ($bad == 0) {
86 if ($ok) {
87 print "All tests successful.\n";
88 } else {
89 die "FAILED--no tests were run for some reason.\n";
90 }
91} else {
92 if ($bad == 1) {
93 die "Failed 1 test.\n";
94 } else {
95 die "Failed $bad tests.\n";
96 }
97}
98($user,$sys,$cuser,$csys) = times;
99print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n",
100 $user,$sys,$cuser,$csys,$files,$totmax);