-
Notifications
You must be signed in to change notification settings - Fork 47
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
Handle exit status from the CLI class #310
Conversation
@@ -10,8 +10,7 @@ end | |||
trap("SIGINT") { raise StackMaster::CtrlC } | |||
|
|||
begin | |||
result = StackMaster::CLI.new(ARGV.dup).execute! | |||
exit !!result | |||
StackMaster::CLI.new(ARGV.dup).execute! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This binstub no longer handles the exit status.
@@ -253,7 +253,7 @@ def execute_stacks_command(command, args, options) | |||
end | |||
end | |||
end | |||
success | |||
@kernel.exit false unless success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI
class now handles the exit status.
Feature: Check the StackMaster version | ||
Scenario: Use the --version option | ||
When I run `stack_master --version` | ||
Then the exit status should be 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a scenario to ensure stack_master --version
results in a 0
status.
@@ -123,6 +123,7 @@ Feature: Apply command | |||
| + "Vpc": { | | |||
| Parameters diff: | | |||
| KeyName: my-key | | |||
And the exit status should be 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate the exit status in all Cucumber scenarios.
@@ -43,7 +43,7 @@ Feature: Apply command with allowed accounts | |||
And I run `stack_master apply us-east-1 myapp-db` | |||
And the output should contain all of these lines: | |||
| Account '11111111' is not an allowed account. Allowed accounts are ["22222222"].| | |||
Then the exit status should be 0 | |||
Then the exit status should be 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of an incorrect Cucumber validation. This scenario was ensuring a status 0
, but because it was only testing via the CLI
class it missed the binstub returning 1
.
Now the feature correctly checks the value returned in the command invocation.
Note: this is not a change in StackMaster behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
This is something we've had a number of regressions in before.
Context
There are a couple of peculiar StackMaster behaviours regarding exit status.
stack_master --version
results in a status of1
(stack_master --version returns a failed exit code #183).stack_master
binstub, but the Cucumber feature suite doesn't test this. It drives StackMaster via theStackMaster::CLI
class directly. This makes validating the status code impossible.Change
I propose we move handling of the exit status into the
StackMaster::CLI
class. This will solve both problems:stack_master --version
will return a status of0
(fixes stack_master --version returns a failed exit code #183).