5 @EXPORT_OK = qw(parse_results);
9 sub parse_results
($$$$$)
11 my ($msg_ops, $statistics, $fh, $expecting_failure, $open_tests) = @_;
12 my $unexpected_ok = 0;
13 my $expected_fail = 0;
14 my $unexpected_fail = 0;
15 my $unexpected_err = 0;
16 my $orig_open_len = $#$open_tests;
19 if (/^test: (.+)\n/) {
20 $msg_ops->control_msg($_);
21 $msg_ops->start_test($open_tests, $1);
22 push (@
$open_tests, $1);
23 } elsif (/^(success|successful|failure|skip|knownfail|error): (.*?)( \[)?([ \t]*)\n/) {
24 $msg_ops->control_msg($_);
28 # reason may be specified in next lines
31 $msg_ops->control_msg($_);
32 if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
35 unless ($terminated) {
36 $statistics->{TESTS_ERROR
}++;
37 $msg_ops->end_test($open_tests, $2, $1, 1, "reason interrupted");
42 if ($1 eq "success" or $1 eq "successful") {
43 pop(@
$open_tests); #FIXME: Check that popped value == $2
44 if ($expecting_failure->(join(".", @
$open_tests) . ".$2")) {
45 $statistics->{TESTS_UNEXPECTED_OK
}++;
46 $msg_ops->end_test($open_tests, $2, $1, 1, $reason);
49 $statistics->{TESTS_EXPECTED_OK
}++;
50 $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
52 } elsif ($1 eq "failure") {
53 pop(@
$open_tests); #FIXME: Check that popped value == $2
54 if ($expecting_failure->(join(".", @
$open_tests) . ".$2")) {
55 $statistics->{TESTS_EXPECTED_FAIL
}++;
56 $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
59 $statistics->{TESTS_UNEXPECTED_FAIL
}++;
60 $msg_ops->end_test($open_tests, $2, $1, 1, $reason);
63 } elsif ($1 eq "knownfail") {
64 pop(@
$open_tests); #FIXME: Check that popped value == $2
65 $statistics->{TESTS_EXPECTED_FAIL
}++;
66 $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
67 } elsif ($1 eq "skip") {
68 $statistics->{TESTS_SKIP
}++;
69 pop(@
$open_tests); #FIXME: Check that popped value == $2
70 $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
71 } elsif ($1 eq "error") {
72 $statistics->{TESTS_ERROR
}++;
73 pop(@
$open_tests); #FIXME: Check that popped value == $2
74 $msg_ops->end_test($open_tests, $2, $1, 1, $reason);
78 $msg_ops->output_msg($_);
82 while ($#$open_tests > $orig_open_len) {
83 $msg_ops->end_test($open_tests, pop(@
$open_tests), "error", 1,
84 "was started but never finished!");
85 $statistics->{TESTS_ERROR
}++;
89 return 1 if $unexpected_err > 0;
90 return 1 if $unexpected_fail > 0;
91 return 1 if $unexpected_ok > 0 and $expected_fail > 0;
92 return 0 if $unexpected_ok > 0 and $expected_fail == 0;
93 return 0 if $expected_fail > 0;