From 7f5dc211ba90974ebdde6d9bd4f38fac919a670a Mon Sep 17 00:00:00 2001 From: Claudia Date: Mon, 8 Dec 2014 12:20:29 +0100 Subject: [PATCH] In `SystemCommand`, fix `success?` and `exit_status` 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. --- lib/cask/system_command.rb | 6 +++--- test/cask/system_command_test.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cask/system_command.rb b/lib/cask/system_command.rb index 45a6ce6718ade..7dc77aac070c6 100644 --- a/lib/cask/system_command.rb +++ b/lib/cask/system_command.rb @@ -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={}) diff --git a/test/cask/system_command_test.rb b/test/cask/system_command_test.rb index 8e17e12609eac..82bad69f75b23 100644 --- a/test/cask/system_command_test.rb +++ b/test/cask/system_command_test.rb @@ -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 doesn’t 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