fix(services/list): correctly handle services with an error code #19502
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
brew services list
command was not correctly handling servicesthat had an error code status.
While the
#zero?
method returns a boolean, the#nonzero?
methodconfusingly returns self or nil. Hence a negated
#zero?
call to checkfor a non-zero exit code fixes the error.
While here,
#pid?
method uses a negated#zero?
, which is notaccurate, as a negative PID value would not be a valid PID. Hence I
changed it to use
#positive?
instead.The tests for the
#error?
method were marked as needing systemd, but Isaw no obvious reason for that due to how they all use mocked values, so
I removed the systemd requirement.
Resolves this error I was getting while the
node_exporter
service had a error status:brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?The one failure I got locally with
brew tests
was fromtest/dev-cmd/tap-new_spec.rb
which seems very unrelated to my fix here: