This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix a2p translation of '{print "a" "b" "c"}'
[perl5.git] / t / TEST
1 #!./perl
2
3 # $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
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     @ARGV = split(/[ \n]/,
24       `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
25 }
26
27 open(CONFIG,"../config.sh");
28 while (<CONFIG>) {
29     if (/sharpbang='(.*)'/) {
30         $sharpbang = ($1 eq '#!');
31         last;
32     }
33 }
34 $sharpbang = 0 if $ENV{OS2_SHELL};              # OS/2
35 $bad = 0;
36 $good = 0;
37 $total = @ARGV;
38 while ($test = shift) {
39     if ($test =~ /^$/) {
40         next;
41     }
42     $te = $test;
43     chop($te);
44     print "$te" . '.' x (15 - length($te));
45     if ($sharpbang) {
46         open(results,"./$test |") || (print "can't run.\n");
47     } else {
48         open(script,"$test") || die "Can't run $test.\n";
49         $_ = <script>;
50         close(script);
51         if (/#!..perl(.*)/) {
52             $switch = $1;
53         } else {
54             $switch = '';
55         }
56         open(results,"./perl$switch $test |") || (print "can't run.\n");
57     }
58     $ok = 0;
59     $next = 0;
60     while (<results>) {
61         if ($verbose) {
62             print $_;
63         }
64         unless (/^#/) {
65             if (/^1\.\.([0-9]+)/) {
66                 $max = $1;
67                 $totmax += $max;
68                 $files += 1;
69                 $next = 1;
70                 $ok = 1;
71             } else {
72                 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
73                 if (/^ok (.*)/ && $1 == $next) {
74                     $next = $next + 1;
75                 } else {
76                     $ok = 0;
77                 }
78             }
79         }
80     }
81     $next = $next - 1;
82     if ($ok && $next == $max) {
83         if ($max) {
84             print "ok\n";
85             $good = $good + 1;
86         } else {
87             print "skipping test on this platform\n";
88             $files -= 1;
89         }
90     } else {
91         $next += 1;
92         print "FAILED on test $next\n";
93         $bad = $bad + 1;
94         $_ = $test;
95         if (/^base/) {
96             die "Failed a basic test--cannot continue.\n";
97         }
98     }
99 }
100
101 if ($bad == 0) {
102     if ($ok) {
103         print "All tests successful.\n";
104     } else {
105         die "FAILED--no tests were run for some reason.\n";
106     }
107 } else {
108     $pct = sprintf("%.2f", $good / $total * 100);
109     if ($bad == 1) {
110         warn "Failed 1 test, $pct% okay.\n";
111     } else {
112         die "Failed $bad/$total tests, $pct% okay.\n";
113     }
114 }
115 ($user,$sys,$cuser,$csys) = times;
116 print sprintf("u=%g  s=%g  cu=%g  cs=%g  files=%d  tests=%d\n",
117     $user,$sys,$cuser,$csys,$files,$totmax);