-
-
Notifications
You must be signed in to change notification settings - Fork 41
Support Bash "strict mode" (and fix one unit test) #239
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
Conversation
A few different kinds of changes are made:
- Optional parameters/variables are changed to ${var-} to default to
empty or given defaults with ${var=...}.
- ((...)) arithmetic evaluation "fails" when the result happens to be
zero, so silence this with "|| true"
This will help ensure that bashunit won't cause problems with tests that use "set -euo pipefail"
Watermelon AI SummaryAI Summary deactivated by djpohly GitHub PRs
bashunit is an open repo and Watermelon will serve it for free. |
Chemaclass
left a comment
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.
Wow, this is pretty cool. Thanks!
|
It seems that it is not working as expected for macos... I will check it out when I find some time these days |
|
I will merge this branch into an internal one with the same name |
Support for Bash strict mode has been added in 0.14: https://bashunit.typeddevs.com/blog/2024-07-14-release-0-14#%F0%9F%8C%BE-miscellaneous TypedDevs/bashunit#239 CI compatible report (JUnit XML format) has been added in 0.14: https://bashunit.typeddevs.com/blog/2024-07-14-release-0-14#logger-junit-xml https://bashunit.typeddevs.com/command-line#junit-logging Parallel execution has been added in 0.18: https://bashunit.typeddevs.com/blog/2024-10-16-release-0-18#running-in-parallel-358
Support for Bash strict mode has been added in 0.14: https://bashunit.typeddevs.com/blog/2024-07-14-release-0-14#%F0%9F%8C%BE-miscellaneous TypedDevs/bashunit#239 CI compatible report (JUnit XML format) has been added in 0.14: https://bashunit.typeddevs.com/blog/2024-07-14-release-0-14#logger-junit-xml https://bashunit.typeddevs.com/command-line#junit-logging Parallel execution has been added in 0.18: https://bashunit.typeddevs.com/blog/2024-10-16-release-0-18#running-in-parallel-358 Mocking is avaliable and the previously linked issue has been merged in 0.20: https://bashunit.typeddevs.com/test-doubles#mock TypedDevs/bashunit#232
📚 Description
Some script authors like to use "unofficial Bash strict mode", enough so that supporting it shows up in comparisons of shell testing frameworks.
Case in point: enabling the -u option uncovered a bug in
test_unsuccessful_assert_is_directory_not_writablethat is fixed in this PR.🔖 Changes
set -euo pipefailenabled.$a_filewas supposed to be$a_directory).((...)), which exit 1 if their result happens to be zero, are fixed with|| true.check_duplicate_functionsdoes not appear to be intended to cause the script to fail, so it is also silenced with|| true.${1-}."${varname=default}".set_up) will not be run instead.✅ To-do list
CHANGELOG.mdto reflect the new feature or fixI updated the documentation to reflect the changes(Not sure there's anything to document, since this fix doesn't require users to do anything different.)