1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2021-09-07 19:01:03 +02:00
parent 95089ddaf4
commit a375640ea5
2 changed files with 7 additions and 5 deletions

View file

@ -135,16 +135,18 @@ def ruby_exe(code = :not_given, opts = {})
code = tmpfile
end
expected_exit_status = opts.fetch(:exit_status, 0)
expected_status = opts.fetch(:exit_status, 0)
begin
platform_is_not :opal do
command = ruby_cmd(code, opts)
output = `#{command}`
last_status = Process.last_status
if last_status.exitstatus != expected_exit_status
raise "Expected exit status is #{expected_exit_status.inspect} but actual is #{last_status.exitstatus.inspect} for command ruby_exe(#{command.inspect})"
exit_status = Process.last_status.exitstatus
if exit_status != expected_status
formatted_output = output.lines.map { |line| " #{line}" }.join
raise SpecExpectationNotMetError,
"Expected exit status is #{expected_status.inspect} but actual is #{exit_status.inspect} for command ruby_exe(#{command.inspect})\nOutput:\n#{formatted_output}"
end
output

View file

@ -145,7 +145,7 @@ RSpec.describe Object, "#ruby_exe" do
stub_const 'RUBY_EXE', 'ruby_spec_exe -w -Q'
@script = RubyExeSpecs.new
allow(@script).to receive(:`)
allow(@script).to receive(:`).and_return('OUTPUT')
status_successful = double(Process::Status, exitstatus: 0)
allow(Process).to receive(:last_status).and_return(status_successful)