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

cdk diff should not exit with error code in case there is a diff #1440

Closed
moshebs opened this issue Dec 27, 2018 · 2 comments · Fixed by #1446
Closed

cdk diff should not exit with error code in case there is a diff #1440

moshebs opened this issue Dec 27, 2018 · 2 comments · Fixed by #1446

Comments

@moshebs
Copy link

moshebs commented Dec 27, 2018

When running cdk diff commandline, the exit code is 1 in case there is a diff. While this might be useful if you are aware of it, it is semantically wrong, because the diff command executed successfully. When you stumble upon it you immediately go and check what you did wrong. I also did not find this behaviour documented anywhere.

@RomainMuller
Copy link
Contributor

The cdk diff behavior is intentionally the same as the GNU diff command, which returns with status 1 when there is a difference, and with 0 when there are none.

This is particularly helpful when trying to come up with tests that assert an app synthesizes to exactly what one expected.

With respects to this behavior not being documented anywhere, you are correct that this should be mentioned.

@RomainMuller
Copy link
Contributor

RomainMuller commented Dec 28, 2018

Submitted a PR to mention the exit behavior of cdk diff expressly in the --help text.

RomainMuller added a commit that referenced this issue Jan 7, 2019
The `cdk diff` command intentionally returns non-zero when a difference is found,
similar to how the POSIX `diff` command behaves (returning 0 when no difference is
found, 1 when some difference is found, and >1 when an error occurred). This
behavior was however undocumented, possibly leading to user confusion.

This change adds a note in `cdk --help` that mentions the exit code 1 will be used
when a difference is found.

Fixes #1440
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 a pull request may close this issue.

2 participants