-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In SystemCommand
, fix success?
and exit_status
#7895
In SystemCommand
, fix success?
and exit_status
#7895
Conversation
Hmm. Travis says Could anyone please give me a hint what I did wrong? |
Good catch. This probably never came up because
But an implicit I'll look into the test failures shortly. |
I have finally managed to reproduce the failing test. The problem seems to be that on my machine, When I run the tests using the cd -P "$(brew --repository)"/Library/Taps/caskroom/homebrew-cask/lib/..
bundle exec rake test TEST=test/syntax_test.rb TESTOPTS="-v" | grep -A2 -B1 'system_command_test.*:$' it says the tests have been skipped: 161) Skipped:
Syntax check::under Ruby 1.9#test_0170_/Users/claudia/Documents/dev/homebrew-cask-dev/test/cask/system_command_test.rb is valid Ruby [/Users/claudia/Documents/dev/homebrew-cask-dev/test/syntax_test.rb:17]:
Skipped, no message given
--
--
352) Skipped:
Syntax check::under Ruby 2.1#test_0170_/Users/claudia/Documents/dev/homebrew-cask-dev/test/cask/system_command_test.rb is valid Ruby [/Users/claudia/Documents/dev/homebrew-cask-dev/test/syntax_test.rb:17]:
Skipped, no message given
--
--
400) Skipped:
Syntax check::under Ruby 1.8#test_0170_/Users/claudia/Documents/dev/homebrew-cask-dev/test/cask/system_command_test.rb is valid Ruby [/Users/claudia/Documents/dev/homebrew-cask-dev/test/syntax_test.rb:17]:
Skipped, no message given Turns out that while As a quick workaround, I just did: ln -s $(rbenv root) ~/.rbenv Now the 1.8 and 1.9 tests actually get executed: 182) Error:
Syntax check::under Ruby 1.9#test_0170_/Users/claudia/Documents/dev/homebrew-cask-dev/test/cask/system_command_test.rb is valid Ruby:
SyntaxError: /Users/claudia/Documents/dev/homebrew-cask-dev/test/cask/system_command_test.rb failed syntax check
/Users/claudia/Documents/dev/homebrew-cask-dev/test/syntax_test.rb:25:in `test_0170_/Users/claudia/Documents/dev/homebrew-cask-dev/test/cask/system_command_test.rb is valid Ruby'
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/usr/local/var/rbenv/versions/1.8.7-p302/lib/ruby/gems/1.8/gems/rake-10.0.4/lib" "/usr/local/var/rbenv/versions/1.8.7-p302/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "test/syntax_test.rb" -v] |
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.
… which in turn helped me see what my actual mistake was: test/cask/system_command_test.rb:27: invalid multibyte char (US-ASCII)
test/cask/system_command_test.rb:27: invalid multibyte char (US-ASCII)
test/cask/system_command_test.rb:27: syntax error, unexpected $end, expecting ')' Turns out that in one of the string literals, I used an apostrophe ( I have now replaced it with a quotation mark. 😬 |
Looks good. I checked that |
In `SystemCommand`, fix `success?` and `exit_status`
Thanks for the review! |
For the upcoming
brew cask search
byname
, I’m going to have to invoke aCask::SystemCommand
with the option:must_succeed => false
and then look at the exit status.Like this:
The issue is that the
SystemCommand::Result#exit_status
method returns the wholeProcess::Status
object instead of aFixnum
.As a workaround, I could have done
result.exit_status.exitstatus
but I think this would be very ugly.Cause
When invoking a
SystemCommand
with the option:must_succeed => false
, the code inSystemCommand
feeds aProcess.Status
object toSystemCommand::Result.new
instead of theFixnum
it expects.Impact
Apart from the usage in the upcoming PR, why didn’t this issue ever come up?
I think this is because:
:must_succeed => true
so there is no need to care aboutexit_status
, and:must_succeed => false
(only the Casksprivate-eye
andsoundflower
do this), no one cares aboutexit_status
.Please review
Pinging @federicobond @ndr-qef @phinze @rolandwalker to ask if one of you could please have a look. Thanks! 😊