7 use FindBin
qw($RealBin);
13 my ($class, $summaryfile, $verbose, $immediate, $statistics, $totaltests) = @_;
16 immediate => $immediate,
17 statistics => $statistics,
23 summaryfile => $summaryfile,
25 totalsuites => $totaltests,
32 sub start_testsuite($$)
34 my ($self, $name) = @_;
37 $self->{NAME} = $name;
38 $self->{START_TIME} = time();
40 my $duration = $self->{START_TIME} - $self->{start_time};
42 $self->{test_output}->{$name} = "" unless($self->{verbose});
45 $out .= "[$self->{index}/$self->{totalsuites} in ".$duration."s";
46 $out .= sprintf(", %d errors", ($#{$self->{suitesfailed}}+1)) if ($#{$self->{suitesfailed}} > -1);
48 if ($self->{immediate}) {
57 my ($self, $output) = @_;
59 if ($self->{verbose}) {
64 $self->{test_output}->{$self->{NAME}} .= $output;
70 my ($self, $output) = @_;
72 $self->output_msg($output);
75 sub end_testsuite($$$$$)
77 my ($self, $name, $result, $unexpected, $reason) = @_;
81 if ($result eq "success" and not defined($reason)) {
82 $reason = "Expected negative exit code, got positive exit code";
84 $self->output_msg("ERROR: $reason\n");
85 push (@{$self->{suitesfailed}}, $name);
90 if ($unexpected and $self->{immediate} and not $self->{verbose}) {
91 $out .= $self->{test_output}->{$name};
94 if (not $self->{immediate}) {
95 if (not $unexpected) {
98 $out .= " " . uc($result) . "\n";
107 my ($self, $parents, $testname) = @_;
109 if ($#$parents == -1) {
110 $self->start_testsuite($testname);
116 my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
118 if ($#$parents == -1) {
119 $self->end_testsuite($testname, $result, $unexpected, $reason);
125 unless ($unexpected) {
126 $self->{test_output}->{$self->{NAME}} = "";
127 if (not $self->{immediate}) {
128 if ($result eq "failure") { print "f"; }
129 elsif ($result eq "skip") { print "s"; }
130 elsif ($result eq "success") { print "."; }
131 else { print "?($result)"; }
136 my $fullname = join(".", @$parents).".$testname";
138 $append = "UNEXPECTED($result): $testname ($fullname)\n";
140 $self->{test_output}->{$self->{NAME}} .= $append;
142 if ($self->{immediate} and not $self->{verbose}) {
143 print $self->{test_output}->{$self->{NAME}};
144 $self->{test_output}->{$self->{NAME}} = "";
147 if (not $self->{immediate}) {
148 if ($result eq "error") { print "E"; }
149 elsif ($result eq "failure") { print "F"; }
150 elsif ($result eq "success") { print "S"; }
159 open(SUMMARY, ">$self->{summaryfile}");
161 if ($#{$self->{suitesfailed}} > -1) {
162 print SUMMARY "= Failed tests =\n";
164 foreach (@{$self->{suitesfailed}}) {
165 print SUMMARY "== $_ ==\n";
166 print SUMMARY $self->{test_output}->{$_}."\n\n";
172 if (not $self->{immediate} and not $self->{verbose}) {
173 foreach (@{$self->{suitesfailed}}) {
174 print "===============================================================================\n";
176 print $self->{test_output}->{$_};
181 print SUMMARY "= Skipped tests =\n";
182 foreach my $reason (keys %{$self->{skips}}) {
183 print SUMMARY "$reason\n";
184 foreach my $name (@{$self->{skips}->{$reason}}) {
185 print SUMMARY "\t$name\n";
191 print "\nA summary with detailed information can be found in:\n $self->{summaryfile}\n";
193 if ($#{$self->{suitesfailed}} == -1) {
194 my $ok = $self->{statistics}->{TESTS_EXPECTED_OK} +
195 $self->{statistics}->{TESTS_EXPECTED_FAIL};
196 print "\nALL OK ($ok tests in $self->{suites_ok} testsuites)\n";
198 print "\nFAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in ". ($#{$self->{suitesfailed}}+1) ." testsuites)\n";
203 sub skip_testsuite($$)
205 my ($self, $name, $reason) = @_;
207 push (@{$self->{skips}->{$reason}}, $name);
209 $self->{totalsuites}--;