| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC'; use Test::More; |
| 6 |
use Test::XML; |
| 7 |
use File::Slurp qw(slurp); |
| 8 |
use File::Spec; |
| 9 |
|
| 10 |
############################################################################### |
| 11 |
# Figure out how many TAP files we have to run. Yes, the results *ARE* going |
| 12 |
# to be different when parsing the raw TAP output than when running under |
| 13 |
# 'prove'; we won't have any context of "did the test die a horrible death?" |
| 14 |
my @tests = grep { -f $_ } <t/data/tap/*>; |
| 15 |
plan tests => scalar(@tests); |
| 16 |
|
| 17 |
############################################################################### |
| 18 |
# Run each of the TAP files in turn through 'tap2junit', and compare the output |
| 19 |
# to the expected JUnit output in each case. |
| 20 |
my $null = File::Spec->devnull(); |
| 21 |
foreach my $test (@tests) { |
| 22 |
(my $junit = $test) =~ s{/tap/}{/tap/junit/}; |
| 23 |
|
| 24 |
my $rc = system(qq{ $^X -Ilib script/tap2junit $test 2>$null }); |
| 25 |
|
| 26 |
my $outfile = "$test.xml"; |
| 27 |
my $received = slurp($outfile); |
| 28 |
unlink $outfile; |
| 29 |
|
| 30 |
my $expected = slurp($junit); |
| 31 |
|
| 32 |
# Compare results (bearing in mind that some tests produce zero output, and |
| 33 |
# thus cannot be parsed as XML) |
| 34 |
if ($received || $expected) { |
| 35 |
is_xml $received, $expected, $test; |
| 36 |
} |
| 37 |
else { |
| 38 |
is $received, $expected, $test; |
| 39 |
} |
| 40 |
} |