sstephenson / bats

Bash Automated Testing System
MIT License
7.12k stars 519 forks source link

Fix call to ../libexec/bats from bin/bats when install/bin/bats is not current dir or parameters are passed #234

Open jonathandandries opened 6 years ago

jonathandandries commented 6 years ago

The following procedure failed:

  1. In "Git Bash" for windows.

  2. $ git clone https://github.com/sstephenson/bats.git

  3. $ ./bats/install.sh /usr/local

    Installed Bats to /usr/local/bin/bats

  4. $ bats mytest.bats

    /usr/local/bin/bats: line 1: ../libexec/bats: No such file or directory

Fixed by modifying bin/bats to be aware of $(dirname $0), and then I figured out that I also needed to pass parameters, hence "$@"

dimo414 commented 6 years ago

This might be a bug in "Git Bash for windows" (I don't know what that is). BATS runs just fine via both WSL and Cygwin. I'd suggest using one of those instead.

jonathandandries commented 6 years ago

Thanks Michael,

Git Bash is just a linux emulator for Windows that you get when you install Git on Windows: https://git-for-windows.github.io/

I reported my environment as FYI, but I honestly think the bug I fixed is going to happen on any environment. The install.sh script is installing a script that is supposed to make a call back to ../libexec/bats. The only way that would work is if you are in the pwd with that script and if you don't pass any parameters.

dimo414 commented 6 years ago

I honestly think the bug I fixed is going to happen on any environment

I can imagine that being true, but empirically it works fine on Linux, Cygwin, WSL, and OSX (and notably the Travis CI is also failing with this PR), which makes it seem a lot more like an issue specific to Git on Windows.

jonathandandries commented 6 years ago

Thanks Michael,

I don't know how it's working, but if it works, go for it. Note I just noticed that the travis-ci build is failing on something that looks to be independent of my change:

"/home/travis/.travis/job_stages: line 57: bin/bats: No such file or directory"

I'm curious if that build works on the master branch as it is.

Cheers,

Jonathan

dimo414 commented 6 years ago

I'm pretty sure the failure is related to your PR - the master branch is passing (though admittedly it's old), and I don't see that error in other recent PRs. Seeing as you're changing how Bats its invoked and loaded a "No such file" error seems likely to be related.

cornfeedhobo commented 5 years ago

On Suse Linux here and having the same issue. The relative lookup breaks when executing from another directory. This patch fixes the issue. Looking forward to seeing this PR merged.

dimo414 commented 5 years ago

You probably want to migrate to https://github.com/bats-core/bats-core

cornfeedhobo commented 5 years ago

I'll follow up with the project I am working on that embeds this as a sub-module, but I still think this should be merged. It's small and the value add is clear. Can't see a downside (although I have no idea what the CI failure is right now).

dimo414 commented 5 years ago

@cornfeedhobo again, migrate to bats-core; this project is dead.

cornfeedhobo commented 5 years ago

I see. thanks.