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
Alias gnu commands for homebrew packaging #172
Conversation
src/beakerlib.sh
Outdated
|
||
# Command aliases for compatibilities | ||
declare READLINK_CMD="readlink" | ||
|
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.
It should be enough to move all the *_CMD
variable definitions here. The individual definitions on other scripts should not be necessary unless someone would like to use them separately which is not expected.
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.
So all scripts source beakerlib.sh
? Is it done recursively like the user's test.sh
-> beakerlib.sh
-> logging.sh
-> beakerlib.sh
? Or is it that the individual .sh
scripts will not work without *_CMD
having been defined beforehand?
What about unit-tests, no need for anything special there as well?
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.
So all scripts source
beakerlib.sh
? Is it done recursively like the user'stest.sh
->beakerlib.sh
->logging.sh
->beakerlib.sh
? Or is it that the individual.sh
scripts will not work without*_CMD
having been defined beforehand?
No, the test sources beakerlib.sh
which would define the variables so the other scripts, which are sourced by the beakerlib.sh, will have it available because they run in the same scope/namespace as they are just sourced, not executed. The individual sub-scripts, e.g. infrastructure.sh
should not be sourced directly.
What about unit-tests, no need for anything special there as well?
I'm wondering how it could be tested differently than just calling some of the affected functions.. The only way I can imagine is be to provide a custom bash function/script as a wrapper which would e.g. echo some additional text which could be caught for an assert. Something like getopt_test() {echo "a getopt wrapper" >&2; getopt "$@"; } GETOPT_CMD='getopt_test'; rlHash 'test';
and then check the "a getopt wrapper" was logged on an error log level.
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.
I was thinking more on the lines of if the unit tests will still work, i.e. do those tests source beakerlib.sh
or infrastructure.sh
directly. If the later, we might need to add a declare
in those places as well.
For writing the unit test for getopt_test
, I am not sure I follow. That would depend on if beakerlib.sh
is sourced, and if we can avoid the whole thing not breaking down if we re-define GETOPT_CMD
.
The only part left is to write the I am not proficient with make enough to figure how to add a $ sed -i "s/declare -r __INTERNAL_GETOPT_CMD=\"getopt\"/declare -r __INTERNAL_GETOPT_CMD=\"${GETOPT_CMD}\"/" src/beakerlib.sh
$ sed -i "s/declare -r __INTERNAL_READLINK_CMD=\"readlink\"/declare -r __INTERNAL_READLINK_CMD=\"${READLINK_CMD}\"/" src/beakerlib.sh |
In order to move this along, I added a naive implementation with 5d39fc9. Feel free to review it. Edit: Finally got it working with homebrew as well https://github.com/LecrisUT/homebrew-tmt/actions/runs/8523574505/job/23346138439?pr=1 |
2b1a3f2
to
c423866
Compare
This is to allow replacing the `getopt` command with a full path alias, e.g. for homebrew Signed-off-by: Cristian Le <[email protected]>
See the previous commit on `getopt` Signed-off-by: Cristian Le <[email protected]>
Signed-off-by: Cristian Le <[email protected]>
Addressing the packaging issue in: Homebrew/homebrew-core#164352 (comment)
getopt
toGETOPT_CMD
readlink
toREADLINK_CMD
sed
these functions. I am not proficient in writing Makefiles manually, can someone help for this?Hopefully the CI can catch any issues with aliasing
Depends-on: #171
Homebrew runner: LecrisUT/homebrew-tmt#1 (I'll try to keep it in sync with this PR)