This patch addresses
https://rt.cpan.org/Public/Bug/Display.html?id=81552
Strictly speaking, this is a test suite issue since the generated XML
remains valid, but some attributes are output in a different order than
expected by the test suite.
However, since I can't think of any simple way to make the tests more
forgiving of the order of the attributes in the XML, I've tweaked the
code to use Tie::IxHash to ensure that the generated XML has the
attributes in the same order as the tests expect them.
--- lib/TAP/Formatter/JUnit/Session.pm
+++ lib/TAP/Formatter/JUnit/Session.pm
@@ -10,6 +10,7 @@
use File::Path qw(mkpath);
use IO::File;
use TAP::Formatter::JUnit::Result;
+use Tie::IxHash;
has 'testcases' => (
is => 'rw',
@@ -104,10 +105,12 @@
if ($timer_enabled) {
unless ($result->is_test) {
my $duration = $result->time - $t_start;
- my $case = $xml->testcase( {
- 'name' => _squeaky_clean('(init)'),
+ tie my %case_attrs, 'Tie::IxHash';
+ %case_attrs = (
'time' => $duration,
- } );
+ 'name' => _squeaky_clean('(init)'),
+ );
+ my $case = $xml->testcase( \%case_attrs );
$self->add_testcase($case);
$t_last_test = $result->time;
}
@@ -136,22 +139,23 @@
if ($bogosity) {
my $cdata = $self->_cdata($content);
my $level = $bogosity->{level};
- $failure = $xml->$level( {
+ tie my %error_attrs, 'Tie::IxHash';
+ %error_attrs = (
type => $bogosity->{type},
message => $bogosity->{message},
- }, $cdata );
+ );
+ $failure = $xml->$level( \%error_attrs, $cdata );
}
# add this test to the XML stream
- my $case = $xml->testcase(
- {
- 'name' => _get_testcase_name($result),
+ tie my %case_attrs, 'Tie::IxHash';
+ %case_attrs = (
(
$timer_enabled ? ('time' => $duration) : ()
),
- },
- $failure,
+ 'name' => _get_testcase_name($result),
);
+ my $case = $xml->testcase( \%case_attrs, $failure, );
$self->add_testcase($case);
# update time of last test seen
@@ -162,10 +166,12 @@
# track time for teardown, if needed
if ($timer_enabled) {
my $duration = $self->parser->end_time - $queue->[-1]->time;
- my $case = $xml->testcase( {
- 'name' => _squeaky_clean('(teardown)'),
+ tie my %case_attrs, 'Tie::IxHash';
+ %case_attrs = (
'time' => $duration,
- } );
+ 'name' => _squeaky_clean('(teardown)'),
+ );
+ my $case = $xml->testcase( \%case_attrs );
$self->add_testcase($case);
}
@@ -225,11 +231,12 @@
}
my @tests = @{$self->testcases()};
- my %attrs = (
- 'name' => _get_testsuite_name($self),
- 'tests' => $testsrun,
+ tie my %attrs, 'Tie::IxHash';
+ %attrs = (
'failures' => $failures,
'errors' => $num_errors,
+ 'tests' => $testsrun,
+ 'name' => _get_testsuite_name($self),
(
$timer_enabled ? ('time' => $time) : ()
),