require Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(parse_results);
use strict;
-sub parse_results($$)
-{
- my ($msg_ops, $fh) = @_;
- my $expected_fail = 0;
- my $open_tests = [];
-
- while(<$fh>) {
- if (/^test: (.+)\n/) {
- $msg_ops->start_test($1);
- push (@$open_tests, $1);
- } elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail): (.*?)( \[)?([ \t]*)( multipart)?\n/) {
- my $result = $1;
- my $testname = $2;
- my $reason = undef;
- if ($3) {
- $reason = "";
- # reason may be specified in next lines
- my $terminated = 0;
- while(<$fh>) {
- if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
- }
-
- unless ($terminated) {
- $msg_ops->end_test($testname, "error",
- "reason ($result) interrupted\n");
- return 1;
- }
- }
- if ($result eq "success" or $result eq "successful") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "success", $reason);
- } elsif ($result eq "xfail" or $result eq "knownfail") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "xfail", $reason);
- $expected_fail++;
- } elsif ($result eq "failure" or $result eq "fail") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "failure", $reason);
- } elsif ($result eq "skip") {
- # Allow tests to be skipped without prior announcement of test
- my $last = pop(@$open_tests);
- if (defined($last) and $last ne $testname) {
- push (@$open_tests, $testname);
- }
- $msg_ops->end_test($testname, "skip", $reason);
- } elsif ($result eq "error") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "error", $reason);
- }
- } else {
- print $_;
- }
- }
-
- while ($#$open_tests+1 > 0) {
- $msg_ops->end_test(pop(@$open_tests), "error",
- "was started but never finished!\n");
- }
-}
-
sub start_test($)
{
my ($testname) = @_;
}
}
-sub skip_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "skip", $reason);
-}
-
-sub fail_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "fail", $reason);
-}
-
-sub success_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "success", $reason);
-}
-
-sub xfail_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "xfail", $reason);
-}
-
sub report_time($)
{
my ($time) = @_;