TAP-Formatter-JUnit
view release on metacpan or search on metacpan
lib/TAP/Formatter/JUnit/Session.pm view on Meta::CPAN
last if ($queue->[$index]->is_plan);
my $stuff = $queue->[$index++];
$content .= "\n" . $stuff->as_string;
}
# create a failure/error element if the test was bogus
my $failure;
my $bogosity = $self->_check_for_test_bogosity($result);
if ($bogosity) {
my $cdata = $self->_cdata($content);
my $level = $bogosity->{level};
$failure = $xml->$level( {
type => $bogosity->{type},
message => $bogosity->{message},
}, $cdata );
}
# add this test to the XML stream
my $case = $xml->testcase(
{
'name' => _get_testcase_name($result),
(
$timer_enabled ? ('time' => $duration) : ()
),
},
lib/TAP/Formatter/JUnit/Session.pm view on Meta::CPAN
my $die_msg;
my $exit = $parser->exit();
if ($exit) {
my $wstat = $parser->wait();
my $status = sprintf("%d (wstat %d, 0x%x)", $exit, $wstat, $wstat);
$die_msg = "Dubious, test returned $status";
}
# add system-out/system-err data, as raw CDATA
my $sys_out = 'system-out';
$sys_out = $xml->$sys_out($captured ? $self->_cdata($captured) : undef);
my $sys_err = 'system-err';
$sys_err = $xml->$sys_err($die_msg ? $self->_cdata("$die_msg\n") : undef);
# update the testsuite with aggregate info on this test suite
#
# tests - total number of tests run
# time - wallclock time taken for test run (floating point)
# failures - number of tests that we detected as failing
# errors - number of errors:
# - passing TODOs
# - if a plan was provided, mismatch between that and the
# number of actual tests that were run
lib/TAP/Formatter/JUnit/Session.pm view on Meta::CPAN
# Cleans up the description of the given test.
sub _clean_test_description {
my $test = shift;
my $desc = $test->description();
return _squeaky_clean($desc);
}
###############################################################################
# Creates a CDATA block for the given data (which is made squeaky clean first,
# so that JUnit parsers like Hudson's don't choke).
sub _cdata {
my ($self, $data) = @_;
$data = _squeaky_clean($data);
return $self->xml->xmlcdata($data);
}
###############################################################################
# Clean a string to the point that JUnit can't possibly have a problem with it.
sub _squeaky_clean {
my $string = shift;
# control characters (except CR and LF)
$string =~ s/([\x00-\x09\x0b\x0c\x0e-\x1f])/"^".chr(ord($1)+64)/ge;
# high-byte characters
$string =~ s/([\x7f-\xff])/'[\\x'.sprintf('%02x',ord($1)).']'/ge;
( run in 0.665 second using v1.01-cache-2.11-cpan-454fe037f31 )