Skip to content

Commit f0a069a

Browse files
authored
Merge pull request #28 from berfarah/patch-2
Don't fail on `nil` `failure.body`
2 parents 3140045 + 440e276 commit f0a069a

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

ruby/bin/annotate

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ puts [
6060
failures.each do |failure|
6161
puts "<details>"
6262
puts "<summary><code>#{failure.name} in #{failure.classname}</code></summary>\n\n"
63-
puts "<code><pre>#{failure.body.chomp.strip}</pre></code>\n\n"
63+
if failure.body
64+
puts "<code><pre>#{failure.body.chomp.strip}</pre></code>\n\n"
65+
end
6466
if failure.job
6567
puts "in <a href=\"##{failure.job}\">Job ##{failure.job}</a>"
6668
end

ruby/tests/annotate_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,23 @@
298298

299299
assert_equal 0, status.exitstatus
300300
end
301+
302+
it "handles empty failure bodies" do
303+
output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/empty-failure-body/")
304+
305+
assert_equal <<~OUTPUT, output
306+
Parsing junit.xml
307+
--- ❓ Checking failures
308+
There is 1 failure/error 😭
309+
--- ✍️ Preparing annotation
310+
1 failure:
311+
312+
<details>
313+
<summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
314+
315+
</details>
316+
OUTPUT
317+
318+
assert_equal 0, status.exitstatus
319+
end
301320
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuite name="rspec" tests="2" skipped="0" failures="0" errors="1" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
3+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 500 if the account is ABC" file="./spec/models/account_spec.rb" time="0.020013"/>
4+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 250 by default" file="./spec/models/account_spec.rb" time="0.967127">
5+
<failure message=" expected: 250 got: 500 (compared using eql?) " type="RSpec::Expectations::ExpectationNotMetError"></failure>
6+
</testcase>
7+
</testsuite>

0 commit comments

Comments
 (0)