Skip to content

Commit 76e9c94

Browse files
committed
[GR-33028] Show the output when ruby_exe() has an unexpected exit status
PullRequest: truffleruby/2860
2 parents c29188b + 9216ac4 commit 76e9c94

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spec/mspec/lib/mspec/helpers/ruby_exe.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,18 @@ def ruby_exe(code = :not_given, opts = {})
135135
code = tmpfile
136136
end
137137

138-
expected_exit_status = opts.fetch(:exit_status, 0)
138+
expected_status = opts.fetch(:exit_status, 0)
139139

140140
begin
141141
platform_is_not :opal do
142142
command = ruby_cmd(code, opts)
143143
output = `#{command}`
144144

145-
last_status = Process.last_status
146-
if last_status.exitstatus != expected_exit_status
147-
raise "Expected exit status is #{expected_exit_status.inspect} but actual is #{last_status.exitstatus.inspect} for command ruby_exe(#{command.inspect})"
145+
exit_status = Process.last_status.exitstatus
146+
if exit_status != expected_status
147+
formatted_output = output.lines.map { |line| " #{line}" }.join
148+
raise SpecExpectationNotMetError,
149+
"Expected exit status is #{expected_status.inspect} but actual is #{exit_status.inspect} for command ruby_exe(#{command.inspect})\nOutput:\n#{formatted_output}"
148150
end
149151

150152
output

0 commit comments

Comments
 (0)