@@ -176,9 +176,10 @@ sub render_event {
176176 # Ignore subtests
177177 return if ( $f -> {' hubs' } && $f -> {' hubs' }-> [0]-> {' nested' } );
178178
179- my $test_num = sprintf ( " %04d" , $event -> {' assert_count' } || $f -> {' assert' }-> {' number' } || die Dumper $event );
179+ my $test_num = $event -> {' assert_count' } || $f -> {' assert' }-> {' number' };
180+ $test_num = sprintf " %04d" , $test_num if defined $test_num ;
180181 my $test_name = _squeaky_clean( $f -> {' assert' }-> {' details' } // ' UNKNOWN_TEST?' );
181- my $test_string = defined $test_name ? " $test_num - $test_name " : $test_num ;
182+ $test_name = join " - " , grep { defined } $test_num , $test_name ;
182183 $test -> {' testsuite' }-> {' tests' }++;
183184
184185 $self -> close_open_failure_testcase( $test , $test_num );
@@ -190,10 +191,10 @@ sub render_event {
190191
191192 if ( $f -> {' amnesty' } && grep { ( $_ -> {' tag' } // ' ' ) eq ' TODO' } @{ $f -> {' amnesty' } } ) { # All TODO Tests
192193 if ( !$f -> {' assert' }-> {' pass' } ) { # Failing TODO
193- push @{ $test -> {' testcase' } }, $self -> xml-> testcase( { ' name' => " $test_string (TODO)" , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } }, " " );
194+ push @{ $test -> {' testcase' } }, $self -> xml-> testcase( { ' name' => " $test_name (TODO)" , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } }, " " );
194195 }
195196 elsif ( $self -> {' allow_passing_todos' } ) { # junit parsers don't like passing TODO tests. Let's just not tell them about it if $ENV{ALLOW_PASSING_TODOS} is set.
196- push @{ $test -> {' testcase' } }, $self -> xml-> testcase( { ' name' => " $test_string (PASSING TODO)" , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } }, " " );
197+ push @{ $test -> {' testcase' } }, $self -> xml-> testcase( { ' name' => " $test_name (PASSING TODO)" , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } }, " " );
197198 }
198199 else { # Passing TODO (Failure) when not allowed.
199200
@@ -204,31 +205,34 @@ sub render_event {
204205 my ($todo_message ) = map { $_ -> {' details' } } grep { $_ -> {' tag' } // ' ' eq ' TODO' } @{ $f -> {' amnesty' } };
205206
206207 push @{ $test -> {' testcase' } }, $self -> xml-> testcase(
207- { ' name' => " $test_string (TODO)" , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } },
208+ { ' name' => " $test_name (TODO)" , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } },
208209 $self -> xml-> error(
209210 { ' message' => $todo_message , ' type' => " TodoTestSucceeded" },
210- $self -> _cdata(" ok $test_string " )
211+ $self -> _cdata(" ok $test_name " )
211212 )
212213 );
213214
214215 }
215216 }
216217 elsif ( $f -> {' assert' }-> {' pass' } ) { # Passing test
217218 push @{ $test -> {' testcase' } }, $self -> xml-> testcase(
218- { ' name' => " $test_string " , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } },
219+ { ' name' => $test_name , ' time' => $run_time , ' classname' => $test -> {' testsuite' }-> {' name' } },
219220 " "
220221 );
221222 }
222223 else { # Failing Test.
223224 $test -> {' testsuite' }-> {' failures' }++;
224225 $test -> {' testsuite' }-> {' errors' }++;
225226
227+ my $message = " not ok" . ( $test_name ? " $test_name " : " " );
228+
226229 # Trap the test information. We can't generate the XML for this test until we get all the diag information.
227230 $test -> {' last_failure' } = {
228- ' test_num' => $test_num ,
229- ' test_name' => $test_name ,
230- ' time' => $run_time ,
231- ' message' => " not ok $test_string \n " ,
231+ ' test_num' => $test_num ,
232+ ' test_name' => $test_name ,
233+ ' time' => $run_time ,
234+ ' message' => $message ,
235+ ' full_message' => " $message \n " ,
232236 };
233237 }
234238
@@ -240,7 +244,7 @@ sub render_event {
240244 foreach my $line ( @{ $f -> {' info' } } ) {
241245 next unless $line -> {' details' };
242246 chomp $line -> {' details' };
243- $test -> {' last_failure' }-> {' message ' } .= " # $line ->{details}\n " ;
247+ $test -> {' last_failure' }-> {' full_message ' } .= " # $line ->{details}\n " ;
244248 }
245249 return ;
246250 }
@@ -293,17 +297,20 @@ sub close_open_failure_testcase {
293297 # This causes the entire suite to choke. We don't want this.
294298 # If we're here already, we've already failed the test. let's just make sure the person reviewing
295299 # it knows the test count was messed up.
296- if ( $fail -> {' test_num' } == $new_test_number ) {
297- $fail -> {' message' } .= " # WARNING This test number has already been seen. Duplicate TEST # in output!\n " ;
300+ if ( defined $fail -> {' test_num' }
301+ && defined $new_test_number
302+ && $fail -> {' test_num' } == $new_test_number )
303+ {
304+ $fail -> {' message' }
305+ .= " # WARNING This test number has already been seen. Duplicate TEST # in output!\n " ;
298306 }
299307
300308 my $xml = $self -> xml;
301309 push @{ $test -> {' testcase' } }, $xml -> testcase(
302- { ' name' => " $fail ->{test_num} - $fail ->{ test_name} " , ' time' => $fail -> {' time' }, ' classname' => $test -> {' testsuite' }-> {' name' } },
310+ { ' name' => $fail -> {' test_name' } , ' time' => $fail -> {' time' }, ' classname' => $test -> {' testsuite' }-> {' name' } },
303311 $xml -> failure(
304- { ' message' => " not ok $fail ->{test_num} - $fail ->{test_name}" , ' type' => ' TestFailed' },
305- $self -> _cdata( $fail -> {' message' } )
306- )
312+ { ' message' => $fail -> {message }, ' type' => ' TestFailed' },
313+ $self -> _cdata( $fail -> {' full_message' } ) )
307314 );
308315
309316 delete $test -> {' last_failure' };
0 commit comments