Skip to content

Commit

Permalink
In SystemCommand, fix success? and exit_status
Browse files Browse the repository at this point in the history
When invoking a `SystemCommand` with `:must_succeed => false`, the `SystemCommand::Result` class would mistake a `Process.Status` object for a `Fixnum`.

This commit fixes this by instantiating `Result` with the actual status code as a number.
  • Loading branch information
claui committed Dec 8, 2014
1 parent c3266d3 commit 7f5dc21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/cask/system_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def self.run(executable, options={})
raw_stderr.close_read

# Ruby 1.8 sets $?. Ruby 1.9+ has raw_wait_thr, and does not set $?.
processed_exit_status = raw_wait_thr.nil? ? $? : raw_wait_thr.value
processed_status = raw_wait_thr.nil? ? $? : raw_wait_thr.value

_assert_success(processed_exit_status, command, processed_stdout) if options[:must_succeed]
_assert_success(processed_status, command, processed_stdout) if options[:must_succeed]

Cask::SystemCommand::Result.new(command, processed_stdout, processed_stderr, processed_exit_status)
Cask::SystemCommand::Result.new(command, processed_stdout, processed_stderr, processed_status.exitstatus)
end

def self.run!(command, options={})
Expand Down
2 changes: 1 addition & 1 deletion test/cask/system_command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
describe "when the exit code is 1" do
before do
# See: https://bugs.ruby-lang.org/issues/1287
skip("Ruby 1.8.7 doesnt see exit statuses") if TestHelper.ruby18?
skip("Ruby 1.8.7 doesn't see exit statuses") if TestHelper.ruby18?
end

describe "and the command must succeed" do
Expand Down

0 comments on commit 7f5dc21

Please sign in to comment.