You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
I installed the bats script in /usr/local (following the instructions). The tool was not working, looked like it couldn't find the libexec path scripts. I also had a second issue where bats tests would not find the script I was trying to run.
For the first issue (libexec) I updated the bats script (in /usr/local/bin/bats) line 55:
Old Line: BATS_LIBEXEC="$(abs_dirname "$0")"
New Line: BATS_LIBEXEC="$(abs_dirname "${BASH_SOURCE[0]}")/../libexec"
This would probably work no matter if bats is installed centrally or if it is pulled into a git project since it's all based on relative path to where the bats script is installed.
The second issue was when I was running bats on scripts in my project. The bats test script could not find my scripts for testing. For example:
cd <my project> --- my .sh scripts and .bats test script is here
/usr/local/bin/bats mytest.bats -- run the bats test
It wouldn't find my script. I updated my bats test like this:
Old: run myscript.sh
New: run ${BATS_TEST_DIRNAME}/myscript.sh
This seems to be something to do with the working directory. I'm not sure but it might be worth while to add something like: cd ${BATS_TEST_DIRNAME} to the bats-exec-test script, maybe between lines 57 and 58?
If the path needs to be saved, another option to save it off in a variable or use pushd / popd.
The instructions for bats seemed to imply that it would find scripts in the current working directory that bats is executed from.
Anyway, let me know if I can provide any other details.
Thanks,
Gary
The text was updated successfully, but these errors were encountered:
I installed the bats script in /usr/local (following the instructions). The tool was not working, looked like it couldn't find the libexec path scripts. I also had a second issue where bats tests would not find the script I was trying to run.
For the first issue (libexec) I updated the bats script (in /usr/local/bin/bats) line 55:
Old Line:
BATS_LIBEXEC="$(abs_dirname "$0")"
New Line:
BATS_LIBEXEC="$(abs_dirname "${BASH_SOURCE[0]}")/../libexec"
This would probably work no matter if bats is installed centrally or if it is pulled into a git project since it's all based on relative path to where the bats script is installed.
The second issue was when I was running bats on scripts in my project. The bats test script could not find my scripts for testing. For example:
It wouldn't find my script. I updated my bats test like this:
Old:
run myscript.sh
New:
run ${BATS_TEST_DIRNAME}/myscript.sh
This seems to be something to do with the working directory. I'm not sure but it might be worth while to add something like:
cd ${BATS_TEST_DIRNAME}
to the bats-exec-test script, maybe between lines 57 and 58?If the path needs to be saved, another option to save it off in a variable or use pushd / popd.
The instructions for bats seemed to imply that it would find scripts in the current working directory that bats is executed from.
Anyway, let me know if I can provide any other details.
Thanks,
Gary
The text was updated successfully, but these errors were encountered: