Created
January 25, 2019 06:20
-
-
Save ernix/c692ecb3233d60947d19cac10ec9fa2a to your computer and use it in GitHub Desktop.
TAP::Format::JUnit: Parse SKIP directives to produce "<skipped />"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 88d965c5740c5ad09a97e1e576fe3bc14abcc382 Mon Sep 17 00:00:00 2001 | |
From: Shin Kojima <[email protected]> | |
Date: Fri, 25 Jan 2019 15:17:18 +0900 | |
Subject: [PATCH] Parse SKIP directives to produce "<skipped />" | |
Signed-off-by: Shin Kojima <[email protected]> | |
--- | |
lib/TAP/Formatter/JUnit/Result.pm | 1 + | |
lib/TAP/Formatter/JUnit/Session.pm | 13 +++++++++++++ | |
t/data/tap/junit/skip | 5 ++++- | |
t/data/tap/junit/skip_nomsg | 5 ++++- | |
t/data/tests/junit/skip | 5 ++++- | |
t/data/tests/junit/skip_nomsg | 5 ++++- | |
6 files changed, 30 insertions(+), 4 deletions(-) | |
diff --git a/lib/TAP/Formatter/JUnit/Result.pm b/lib/TAP/Formatter/JUnit/Result.pm | |
index 5803334..a95a585 100644 | |
--- a/lib/TAP/Formatter/JUnit/Result.pm | |
+++ b/lib/TAP/Formatter/JUnit/Result.pm | |
@@ -23,6 +23,7 @@ has 'result' => ( | |
is_plan | |
is_unplanned | |
is_ok | |
+ has_skip | |
todo_passed | |
explanation | |
diff --git a/lib/TAP/Formatter/JUnit/Session.pm b/lib/TAP/Formatter/JUnit/Session.pm | |
index fb7dca3..33683e6 100644 | |
--- a/lib/TAP/Formatter/JUnit/Session.pm | |
+++ b/lib/TAP/Formatter/JUnit/Session.pm | |
@@ -142,6 +142,12 @@ sub close_test { | |
}, $cdata ); | |
} | |
+ # create a skipped element if the test was skipped | |
+ my $skipped; | |
+ if ($result->has_skip()) { | |
+ $skipped = $xml->skipped(); | |
+ } | |
+ | |
# add this test to the XML stream | |
my $case = $xml->testcase( | |
{ | |
@@ -151,6 +157,7 @@ sub close_test { | |
), | |
}, | |
$failure, | |
+ $skipped, | |
); | |
$self->add_testcase($case); | |
@@ -203,6 +210,7 @@ sub close_test { | |
my $testsrun = $parser->tests_run() || 0; | |
my $time = $parser->end_time() - $parser->start_time(); | |
my $failures = $parser->failed(); | |
+ my $skipped = $parser->skipped() || 0; | |
my $noplan = $parser->plan() ? 0 : 1; | |
my $planned = $parser->tests_planned() || 0; | |
@@ -233,6 +241,9 @@ sub close_test { | |
( | |
$timer_enabled ? ('time' => $time) : () | |
), | |
+ ( | |
+ $skipped > 0 ? ('skipped' => $skipped) : () | |
+ ), | |
); | |
my $testsuite = $xml->testsuite(\%attrs, @tests, $sys_out, $sys_err, $suite_err); | |
$self->formatter->add_testsuite($testsuite); | |
@@ -283,6 +294,8 @@ sub _check_for_test_bogosity { | |
my $self = shift; | |
my $result = shift; | |
+ return if $result->has_skip(); | |
+ | |
if ($result->todo_passed() && !$self->passing_todo_ok()) { | |
return { | |
level => 'error', | |
diff --git a/t/data/tap/junit/skip b/t/data/tap/junit/skip | |
index 4ad97aa..761a3e0 100644 | |
--- a/t/data/tap/junit/skip | |
+++ b/t/data/tap/junit/skip | |
@@ -1,10 +1,13 @@ | |
<testsuites> | |
<testsuite failures="0" | |
+ skipped="1" | |
errors="0" | |
tests="5" | |
name="data_tap_skip"> | |
<testcase name="1"></testcase> | |
- <testcase name="2"></testcase> | |
+ <testcase name="2"> | |
+ <skipped /> | |
+ </testcase> | |
<testcase name="3"></testcase> | |
<testcase name="4"></testcase> | |
<testcase name="5"></testcase> | |
diff --git a/t/data/tap/junit/skip_nomsg b/t/data/tap/junit/skip_nomsg | |
index d5016e3..df6cb2a 100644 | |
--- a/t/data/tap/junit/skip_nomsg | |
+++ b/t/data/tap/junit/skip_nomsg | |
@@ -1,9 +1,12 @@ | |
<testsuites> | |
<testsuite failures="0" | |
+ skipped="1" | |
errors="0" | |
tests="1" | |
name="data_tap_skip_nomsg"> | |
- <testcase name="1"></testcase> | |
+ <testcase name="1"> | |
+ <skipped /> | |
+ </testcase> | |
<system-out><![CDATA[1..1 | |
ok 1 # Skip | |
]]></system-out> | |
diff --git a/t/data/tests/junit/skip b/t/data/tests/junit/skip | |
index 434c0c0..aec74f5 100644 | |
--- a/t/data/tests/junit/skip | |
+++ b/t/data/tests/junit/skip | |
@@ -1,10 +1,13 @@ | |
<testsuites> | |
<testsuite failures="0" | |
+ skipped="1" | |
errors="0" | |
tests="5" | |
name="data_tests_skip"> | |
<testcase name="1"></testcase> | |
- <testcase name="2"></testcase> | |
+ <testcase name="2"> | |
+ <skipped /> | |
+ </testcase> | |
<testcase name="3"></testcase> | |
<testcase name="4"></testcase> | |
<testcase name="5"></testcase> | |
diff --git a/t/data/tests/junit/skip_nomsg b/t/data/tests/junit/skip_nomsg | |
index 26ac6ed..3cc6233 100644 | |
--- a/t/data/tests/junit/skip_nomsg | |
+++ b/t/data/tests/junit/skip_nomsg | |
@@ -1,9 +1,12 @@ | |
<testsuites> | |
<testsuite failures="0" | |
+ skipped="1" | |
errors="0" | |
tests="1" | |
name="data_tests_skip_nomsg"> | |
- <testcase name="1"></testcase> | |
+ <testcase name="1"> | |
+ <skipped /> | |
+ </testcase> | |
<system-out><![CDATA[1..1 | |
ok 1 # Skip | |
]]></system-out> | |
-- | |
2.20.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment