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

Let 'cve-bin-tool --version' return success #2524

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

raboof
Copy link
Contributor

@raboof raboof commented Jan 11, 2023

Previously, cve-bin-tool --version returned an error code of '2', as if it was an invalid argument.

With this change, it returns successfully, consistent with standard argparse behavior.

# Check command line parameters - wrong option
with pytest.raises(SystemExit) as e:
main(["cve-bin-tool", "-S", "ALL", self.tempdir])
assert e.value.args[0] == ERROR_CODES[SystemExit]
assert e.value.args[0] == 2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a fine line between 'make tests DRY and human-readable' and 'avoid depending on internals in tests'.

In this case I think this is an improvement, since SystemExit may carry various exit codes.

Previously, `cve-bin-tool --version` returned an error code of '2',
as if it was an invalid argument.

With this change, it returns successfully, consistent with standard
argparse behavior.
@raboof raboof force-pushed the show-version-without-error-code branch from 6460af7 to 6f9bd56 Compare January 11, 2023 17:14
Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

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

Thanks for spotting this -- I'd never had reason to check the return code on --version but it's definitely not correct to have it return a failure code.

I'm sure someone's going to find this confusing in the future but I agree with you that there's not exactly a best answer, so let's go with this and we can always iterate to improve if we think of something better later.

@terriko terriko merged commit d4e57cb into intel:main Jan 11, 2023
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.

2 participants