Skip to content
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

Return non-zero exit codes when something goes wrong (WIP) #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MinasMazar
Copy link
Contributor

@MinasMazar MinasMazar commented Apr 27, 2017

This close #52

Some references around the web (like this) tells that is a standard to return a value of 0 when the command performed successfully and a value different form 0 otherwise.

So this is the exit_status table for our project:

CASE EXIT CODE
all commands successfully terminated 0
invalid pulsar parameters 1
other exceptions 1

IMPORTANT

I think this PR will never solve the related issue: there is an unresolvable conflict between Kernel::exit and simplecov gem. Maybe the cause is related to at_exit callback used by simplecov. I noticed many unpredictable weirds behaviors. I tried to keep tests green and full coverage, with many tricks and workarounds but I lost the challenge.

NB. The statement with Kernel::exit method is not covered by default by ruby built-in coverage mechanism, so in any case we'll get a 100% coverage result when using this method.

module Pulsar
module Executor
def self.sh(cmd)
_stdin, _stdout, _stderr, _wait_thr = Open3.popen3(cmd)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use prefix _ for a variable that is used.

@MinasMazar MinasMazar force-pushed the exit-code branch 3 times, most recently from 8d434c4 to a2b58ad Compare April 28, 2017 08:40
@@ -91,5 +104,7 @@ def load_option_or_env!(option)

option_value
end

def self.exit_on_failure?; true; end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private (on line 84) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.

@kennyadsl
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return non-zero exit codes when something goes wrong
3 participants