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
fix: insert error handling in list-all & download plugin scripts #881
Conversation
check the plugin return code is 0 if not print all outputs from plugin and exit 1
Thanks for the PR! I think there are a couple things we need to do before merging this:
Thanks for the PR! This is a good improvement. |
refactor testing to detect broken plugins add list-all command to testing refactor 2 list tests to include broken plugin split some test asertions to aid readability
Refactored to include tests - which included fixed 2 existing tests. |
@laidbackware changes look good! I did leave two comments, one about printing failure output to STDERR, and the other is a question about the tests. Let me know if you will address these comments or if you would like me to make the STDERR change before merging. |
@Stratus3D I have also been thinking about another edge case which I'd be interested on your thoughts on before implementing. This change is currently written to redirect all STDOUT and STDERR data to a single variable when calling list-all. This is fine if the plugin generates an error, but may cause issues if a plugin uses a tool which happens to write to STDERR under normal operation as some linux tools do. asdf/lib/commands/command-list-all.bash Line 12 in e2c4f7c
In this case it would skew the output of the asdf command. The only clean solution I can think of to split the output is to acutally call the list-all script twice. Once just capturing STDOUT which is printed if no errrors occur, but if there is an error it is run a second time to capture STDOUT and STDERR. What do you think? |
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.
LGTM. @Stratus3D ?
update dummy plugin to include error to ignore update broken plugin to add stderr output update list-all test to check for stderr on failure update list-all test to check for no stderr on success
@Stratus3D @jthegedus I think I've solved the issue I mentioned previously without calling the plugin twice. I was concerned that if there were network timeouts, calling the plugin twice could be worse for the user. |
Thanks very much for contributing this @laidbackware Really appreciate it 😄 |
Sorry @laidbackware for never responding, looks great :) |
Summary
This fix will check if a plugin does not exit 0 when calling list-all or download. In the case of an error it will print all stdout and stderr returned by the plugin and then the list all script will exit 1.
Without this fix, it is not possible to test a plugin using CI and get reliable results, as errors are not handled.
Fixes: This fixes #880 and #886
Other Information
This has been tested on Linux and MacOS to be working as expected.
Thank you for contributing to asdf!