63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/pdk/tests/unit.rb', line 63
def self.invoke(report, options = {})
PDK::Util::Bundler.ensure_bundle!
PDK::Util::Bundler.ensure_binstubs!('rake')
setup
tests = options.fetch(:tests)
spinner_msg = options.key?(:parallel) ? _('Running unit tests in parallel.') : _('Running unit tests.')
result = rake(cmd(tests, options), spinner_msg, 'CI_SPEC_OPTIONS' => '--format j')
json_result = if options.key?(:parallel)
PDK::Util.find_all_json_in(result[:stdout])
else
PDK::Util.find_first_json_in(result[:stdout])
end
if parallel_with_no_tests?(options.key?(:parallel), json_result, result)
json_result = [{ 'messages' => ['No examples found.'] }]
result[:exit_code] = 0
end
raise PDK::CLI::FatalError, _('Unit test output did not contain a valid JSON result: %{output}') % { output: result[:stdout] } if json_result.nil? || json_result.empty?
json_result = merge_json_results(json_result, result[:duration]) if options.key?(:parallel)
parse_output(report, json_result)
result[:exit_code]
ensure
tear_down
end
|