Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

BATS libexec dir on install #253

Open
ggordham opened this issue Jan 25, 2018 · 1 comment
Open

BATS libexec dir on install #253

ggordham opened this issue Jan 25, 2018 · 1 comment

Comments

@ggordham
Copy link

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

@Potherca
Copy link

Potherca commented Apr 25, 2018

This project is no longer being actively maintained by its original auther (see #236).

You might want to migrate to the community maintained fork bats-core and report your issue there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants