Skip to content

Commit d31c980

Browse files
authored
Merge pull request #3 from harvesthq/handle-no-message-errors
Handle test failures with no message
2 parents 2094390 + a45125b commit d31c980

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

ruby/bin/annotate

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Failure < Struct.new(:element, :testcase, :testsuite)
4848
def message
4949
message = element.attributes['message'];
5050
if message.nil? || message.empty?
51-
nil
51+
element.attributes['type'].to_s
5252
else
5353
message.to_s
5454
end
@@ -71,10 +71,10 @@ junit_report_files = Dir.glob(File.join(junits_dir, "**", "*"))
7171
stats = { skipped: 0, failures: 0, tests: 0, assertions: 0, time: 0.0 }
7272
failures = []
7373

74+
STDERR.puts "Parsing #{junit_report_files.length} junit file#{junit_report_files.length == 1 ? '' : 's'}"
7475
junit_report_files.sort.each do |file|
7576
next if File.directory?(file)
7677

77-
STDERR.puts "Parsing #{file.sub(junits_dir, '')}"
7878
xml = File.read(file)
7979
doc = REXML::Document.new(xml)
8080

ruby/tests/annotate_test.rb

+17-11
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@ def test_minitest_files
66
output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/minitest/")
77

88
assert_equal <<~OUTPUT, output
9-
Parsing TEST-AccountTest.xml
10-
Parsing TEST-ClientForecastSyncingTest.xml
11-
Parsing TEST-ClientTest.xml
12-
Parsing TEST-CompanyTest.xml
13-
Parsing TEST-UserBillableRatesTest.xml
14-
Parsing TEST-UserCostRatesTest.xml
15-
Parsing TEST-UserTest.xml
9+
Parsing 8 junit files
1610
--- ❓ Checking failures
17-
Ran 330 tests in 21.04s.
18-
There are 3 failures/errors 😭
11+
Ran 331 tests in 22.03s.
12+
There are 4 failures/errors 😭
1913
--- ✍️ Preparing annotation
20-
Ran **330** tests in **21.04s**.
14+
Ran **331** tests in **22.03s**.
2115
<details>
2216
<summary><code>AccountTest#test_harvest_accounts_have_the_name_limited_to_90_characters</code></summary>
2317
@@ -53,6 +47,18 @@ def test_minitest_files
5347
test/models/company_test.rb:2287:in `block (2 levels) in &lt;class:CompanyTest&gt;&#39;</code></pre>
5448
5549
</details>
50+
51+
<details>
52+
<summary><code>PayPalHelperTest#test_PayPal-availability-check_for_customers_in_india_doesn't_raise_if_company_has_been_deleted</code></summary>
53+
54+
<pre class=\"term\"><code>OpenSSL::Cipher::CipherError
55+
56+
app/models/asana_settings.rb:122:in `access_token&#39;
57+
app/models/asana_settings.rb:100:in `revoke_token&#39;
58+
app/models/company.rb:421:in `destroy&#39;
59+
test/helpers/pay_pal_helper_test.rb:93:in `block in &lt;class:PayPalHelperTest&gt;&#39;</code></pre>
60+
61+
</details>
5662
OUTPUT
5763

5864
assert_equal 0, status.exitstatus
@@ -62,7 +68,7 @@ def test_rspec_files
6268
output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/rspec/")
6369

6470
assert_equal <<~OUTPUT, output
65-
Parsing rspec.xml
71+
Parsing 1 junit file
6672
--- ❓ Checking failures
6773
Ran 11 tests in 76.93s.
6874
There is 1 failure/error 😭
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuite time='0.993586' skipped='0' failures='0' errors='1' name="PayPalHelperTest" assertions='1' tests='1' timestamp="2024-04-10T19:38:51+00:00">
3+
<testcase time='0.993586' file="test/helpers/pay_pal_helper_test.rb" name="test_PayPal-availability-check_for_customers_in_india_doesn&#39;t_raise_if_company_has_been_deleted" assertions='1'>
4+
<error type='OpenSSL::Cipher::CipherError' message="">app/models/asana_settings.rb:122:in `access_token&#39;
5+
app/models/asana_settings.rb:100:in `revoke_token&#39;
6+
app/models/company.rb:421:in `destroy&#39;
7+
test/helpers/pay_pal_helper_test.rb:93:in `block in &lt;class:PayPalHelperTest&gt;&#39;
8+
</error>
9+
</testcase>
10+
</testsuite>

0 commit comments

Comments
 (0)