| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC'; use Test::More tests => 2; |
| 6 |
use File::Slurp qw(slurp); |
| 7 |
use File::Spec; |
| 8 |
|
| 9 |
############################################################################### |
| 10 |
# TEST: Run "tap2junit" and let it name the test in the JUnit automatically. |
| 11 |
tap2junit_default_name: { |
| 12 |
my $test_file = 't/data/tap/simple'; |
| 13 |
my $xml_file = "$test_file.xml"; |
| 14 |
|
| 15 |
_tap2junit($test_file); |
| 16 |
my $xml = slurp($xml_file); |
| 17 |
|
| 18 |
unlink $xml_file; |
| 19 |
|
| 20 |
like $xml, qr/<testsuite[^>]+name="data_tap_simple"/m, |
| 21 |
'default name based on TAP filename'; |
| 22 |
} |
| 23 |
|
| 24 |
############################################################################### |
| 25 |
# TEST: Run "tap2junit" with "--name" and rename a test |
| 26 |
tap2junit_name: { |
| 27 |
my $test_file = 't/data/tap/simple'; |
| 28 |
my $xml_file = "$test_file.xml"; |
| 29 |
|
| 30 |
_tap2junit($test_file, '--name', 'foo'); |
| 31 |
my $xml = slurp($xml_file); |
| 32 |
|
| 33 |
unlink $xml_file; |
| 34 |
|
| 35 |
like $xml, qr/<testsuite[^>]+name="foo"/m, 'name explicitly provided'; |
| 36 |
} |
| 37 |
|
| 38 |
sub _tap2junit { |
| 39 |
my @args = @_; |
| 40 |
my $null = File::Spec->devnull(); |
| 41 |
system(qq{ $^X -Ilib script/tap2junit @args 2>$null }); |
| 42 |
} |