Skip to content

Commit b67a4fb

Browse files
committed
Added skipped tests reporting and corresponding ruby test
1 parent ae774ba commit b67a4fb

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

ruby/bin/annotate

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ puts "Errors: #{tests[:error].length}"
8181
puts "Skipped: #{tests[:skipped].length}"
8282
puts "Total tests: #{testcases}"
8383

84-
tests.delete(:skipped) unless ENV.fetch('BUILDKITE_PLUGIN_JUNIT_ANNOTATE_SKIPPED_FORMAT', 'none') != 'none'
84+
skipped = tests.delete(:skipped) # save value for later
8585

8686
tests.values.flatten.each do |failure|
8787
puts ""
@@ -115,4 +115,17 @@ if report_slowest > 0
115115
puts "</details>"
116116
end
117117

118+
if ENV.fetch('BUILDKITE_PLUGIN_JUNIT_ANNOTATE_SKIPPED_FORMAT', 'none') != 'none'
119+
STDERR.puts "Reporting skipped tests"
120+
puts ""
121+
puts "<details>"
122+
puts "<summary>#{skipped.length} tests skipped</summary>\n\n"
123+
puts "<ol>"
124+
skipped.each do |sk|
125+
puts "<li>#{CGI.escapeHTML sk.name} in #{CGI.escapeHTML sk.unit_name} (#{CGI.escapeHTML sk.message || "no reason"})</li>\n"
126+
end
127+
puts "</ol>"
128+
puts "</details>"
129+
end
130+
118131
exit 64 if tests.values.flatten.any? # special exit code to signal test failures

ruby/tests/annotate_test.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,31 @@
600600

601601
assert_equal 0, status.exitstatus
602602
end
603+
604+
it "can report skipped tests" do
605+
stdout, stderr, status = Open3.capture3("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_SKIPPED_FORMAT=classname", "#{__dir__}/../bin/annotate", "#{__dir__}/skipped-test/")
606+
607+
assert_equal stderr, <<~OUTPUT
608+
Parsing junit.xml
609+
--- ✍️ Preparing annotation
610+
Reporting skipped tests
611+
OUTPUT
612+
613+
assert_equal stdout, <<~OUTPUT
614+
Failures: 0
615+
Errors: 0
616+
Skipped: 1
617+
Total tests: 2
618+
619+
<details>
620+
<summary>1 tests skipped</summary>
621+
622+
<ol>
623+
<li>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec (because of reasons)</li>
624+
</ol>
625+
</details>
626+
OUTPUT
627+
628+
assert_equal 0, status.exitstatus
629+
end
603630
end

0 commit comments

Comments
 (0)