This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Mention when tests were skipped instead of passed
[perl5.git] / t / TEST
CommitLineData
8d063cd8
LW
1#!./perl
2
79072805 3# $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $
8d063cd8
LW
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
a687059c
LW
8$| = 1;
9
8d063cd8
LW
10if ($ARGV[0] eq '-v') {
11 $verbose = 1;
12 shift;
13}
14
378cc40b
LW
15chdir 't' if -f 't/TEST';
16
4633a7c4
LW
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
748a9306 21
8d063cd8 22if ($ARGV[0] eq '') {
fe14fcc3
LW
23 @ARGV = split(/[ \n]/,
24 `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`);
8d063cd8
LW
25}
26
5303340c
LW
27open(CONFIG,"../config.sh");
28while (<CONFIG>) {
135863df
AB
29 if (/sharpbang='(.*)'/) {
30 $sharpbang = ($1 eq '#!');
31 last;
32 }
33}
96e55a2d 34$sharpbang = 0 if $ENV{OS2_SHELL}; # OS/2
8d063cd8 35$bad = 0;
79072805
LW
36$good = 0;
37$total = @ARGV;
8d063cd8 38while ($test = shift) {
fe14fcc3 39 if ($test =~ /^$/) {
378cc40b
LW
40 next;
41 }
fe14fcc3
LW
42 $te = $test;
43 chop($te);
44 print "$te" . '.' x (15 - length($te));
135863df 45 if ($sharpbang) {
a0d0e21e 46 open(results,"./$test |") || (print "can't run.\n");
135863df 47 } else {
378cc40b 48 open(script,"$test") || die "Can't run $test.\n";
135863df
AB
49 $_ = <script>;
50 close(script);
51 if (/#!..perl(.*)/) {
52 $switch = $1;
53 } else {
54 $switch = '';
55 }
a0d0e21e 56 open(results,"./perl$switch $test |") || (print "can't run.\n");
135863df 57 }
8d063cd8 58 $ok = 0;
378cc40b 59 $next = 0;
8d063cd8
LW
60 while (<results>) {
61 if ($verbose) {
62 print $_;
63 }
64 unless (/^#/) {
65 if (/^1\.\.([0-9]+)/) {
66 $max = $1;
2b317908
LW
67 $totmax += $max;
68 $files += 1;
8d063cd8
LW
69 $next = 1;
70 $ok = 1;
71 } else {
7e1cf235 72 $next = $1, $ok = 0, last if /^not ok ([0-9]*)/;
8d063cd8
LW
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) {
bcce72a7 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 }
8d063cd8
LW
90 } else {
91 $next += 1;
92 print "FAILED on test $next\n";
93 $bad = $bad + 1;
94 $_ = $test;
95 if (/^base/) {
378cc40b 96 die "Failed a basic test--cannot continue.\n";
8d063cd8
LW
97 }
98 }
99}
100
101if ($bad == 0) {
102 if ($ok) {
103 print "All tests successful.\n";
104 } else {
378cc40b 105 die "FAILED--no tests were run for some reason.\n";
8d063cd8
LW
106 }
107} else {
79072805 108 $pct = sprintf("%.2f", $good / $total * 100);
8d063cd8 109 if ($bad == 1) {
79072805 110 warn "Failed 1 test, $pct% okay.\n";
8d063cd8 111 } else {
79072805 112 die "Failed $bad/$total tests, $pct% okay.\n";
8d063cd8
LW
113 }
114}
115($user,$sys,$cuser,$csys) = times;
2b317908
LW
116print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n",
117 $user,$sys,$cuser,$csys,$files,$totmax);