Cast message_lines in exception to Array
What does this MR do and why?
It appears that test_result.rb#118
sometimes fails in the case that exception['message_lines']
returns a String
rather than an Array
.
Failures:
+Click to expand failure stack trace
NoMethodError: undefined method `each' for # /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/test_result.rb:118:in `block in failures_from_exceptions' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/test_result.rb:112:in `map' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/test_result.rb:112:in `failures_from_exceptions' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/test_result.rb:21:in `initialize' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/test_result.rb:10:in `new' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/test_result.rb:10:in `from_json' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/json_test_results.rb:23:in `block in process' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/json_test_results.rb:22:in `map' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/json_test_results.rb:22:in `process' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/base_test_results.rb:14:in `initialize' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/generate_test_session.rb:24:in `new' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/generate_test_session.rb:24:in `block in run!' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/generate_test_session.rb:21:in `each' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/generate_test_session.rb:21:in `flat_map' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/generate_test_session.rb:21:in `run!' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/report/report_as_issue.rb:20:in `invoke!' /builds/gitlab-org/gitlab-qa-mirror/lib/gitlab/qa/reporter.rb:103:in `invoke' exe/gitlab-qa-report:9:in `'
I suspect that the JSON will spit out a String if only one message appears.
// When only one message exists:
{
"message_lines": "message1"
}
// When more than one message exists:
{
"message_lines": [ "message1", "message2" ]
}
Proof of concept
irb> Array('test')
["test"]
irb> Array(['test1', 'test2'])
["test1", "test2"]
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by James Nutt