5 @EXPORT_OK = qw(parse_results);
9 sub parse_results($$$$$$)
11 my ($msg_ops, $msg_state, $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($msg_state, $_);
21 $msg_ops->start_test($msg_state, $open_tests, $1);
22 push (@$open_tests, $1);
23 } elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) {
24 $msg_ops->control_msg($msg_state, $_);
28 # reason may be specified in next lines
30 $msg_ops->control_msg($msg_state, $_);
31 if ($_ eq "]\n") { last; } else { $reason .= $_; }
35 if ($1 eq "success" or $1 eq "successful") {
36 pop(@$open_tests); #FIXME: Check that popped value == $2
37 if ($expecting_failure->("$msg_state->{NAME}/$2")) {
38 $statistics->{TESTS_UNEXPECTED_OK}++;
39 $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason);
42 $statistics->{TESTS_EXPECTED_OK}++;
43 $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason);
45 } elsif ($1 eq "failure") {
46 pop(@$open_tests); #FIXME: Check that popped value == $2
47 if ($expecting_failure->("$msg_state->{NAME}/$2")) {
48 $statistics->{TESTS_EXPECTED_FAIL}++;
49 $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason);
52 $statistics->{TESTS_UNEXPECTED_FAIL}++;
53 $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason);
56 } elsif ($1 eq "skip") {
57 $statistics->{TESTS_SKIP}++;
58 pop(@$open_tests); #FIXME: Check that popped value == $2
59 $msg_ops->end_test($msg_state, $open_tests, $2, $1, 0, $reason);
60 } elsif ($1 eq "error") {
61 $statistics->{TESTS_ERROR}++;
62 pop(@$open_tests); #FIXME: Check that popped value == $2
63 $msg_ops->end_test($msg_state, $open_tests, $2, $1, 1, $reason);
67 $msg_ops->output_msg($msg_state, $_);
71 while ($#$open_tests > $orig_open_len) {
72 $msg_ops->end_test($msg_state, $open_tests, pop(@$open_tests), "error", 1,
73 "was started but never finished!");
74 $statistics->{TESTS_ERROR}++;
78 return 1 if $unexpected_err > 0;
79 return 1 if $unexpected_fail > 0;
80 return 1 if $unexpected_ok > 0 and $expected_fail > 0;
81 return 0 if $unexpected_ok > 0 and $expected_fail == 0;
82 return 0 if $expected_fail > 0;