Skip to content
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

bats fails to run #127

Closed
iva2k opened this issue Apr 1, 2021 · 3 comments
Closed

bats fails to run #127

iva2k opened this issue Apr 1, 2021 · 3 comments

Comments

@iva2k
Copy link
Contributor

iva2k commented Apr 1, 2021

There are issues in bats:

npm run test:cli

output:

.../node_modules/bats/libexec/bats-core/bats: line 234: exec: bats-exec-suite: not found
.../node_modules/bats/libexec/bats-core/bats: line 234: bats-format-pretty: command not found

Trying to add '$BATS_ROOT/libexec/bats-core/' before each offending file resolves the errors, but there are few more such bare invocations across other files that fail the same. Adding the fix to each of them allows bats command to pass.

Environment:

Windows 10
bash for git: GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)

I suspect that setting up PATH variable could fix it (add resolved $BATS_ROOT/libexec/bats-core/), but it is not the right fix.

@iva2k iva2k changed the title bats package no longer maintained, switch to bats-core bats fails to run Apr 1, 2021
@iva2k
Copy link
Contributor Author

iva2k commented Apr 2, 2021

I figured out what is happening.

Using git bash on Windows 10, so it is bash WIndows issue.

I peeked into value of BATS_LIBEXEC set in bats script and added to PATH:

BATS_LIBEXEC="$(dirname "$(bats_readlinkf "${BASH_SOURCE[0]}")")"
export BATS_LIBEXEC
...
export PATH="$BATS_LIBEXEC;$PATH;."
...
# Added for debug of https://github.com/plasticrake/tplink-smarthome-api/issues/127
echo "BATS_LEBEXEC=$BATS_LIBEXEC"
BATS_LIBEXEC=C:/.../node_modules/bats/libexec/bats-core

When I run in bash:

export BATS_LIBEXEC=C:/.../node_modules/bats/libexec/bats-core
which bats-exec-suite

It gets an error:

which: no bats-exec-suite in (C:/.../node_modules/bats/libexec/bats-core:

Changing Windows-specific "C:/..." to bash-accepted form "/c/...":

export BATS_LIBEXEC=/c/.../node_modules/bats/libexec/bats-core
which bats-exec-suite

It gets no error:

/c/.../node_modules/bats/libexec/bats-core:

So in summary, bash on windows dirname returns "C:/...", but using it in PATH does not work, need to be "/c/...".

@iva2k
Copy link
Contributor Author

iva2k commented Apr 2, 2021

The following fix makes bats run ok:

file node_modules/bats/libexec/bats-core/bats

- BATS_LIBEXEC="$(dirname "$(bats_readlinkf "${BASH_SOURCE[0]}")")"
+ BATS_LIBEXEC="$(cd "$(dirname "$(bats_readlinkf "${BASH_SOURCE[0]}")")"; pwd)"

@iva2k
Copy link
Contributor Author

iva2k commented Apr 2, 2021

Posted issue and solution to
bats-core/bats-core#424

Closing here.

@iva2k iva2k closed this as completed Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant