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

Make load handle free filename too #147

Closed
wants to merge 1 commit into from
Closed

Make load handle free filename too #147

wants to merge 1 commit into from

Conversation

kawaz
Copy link

@kawaz kawaz commented Feb 2, 2016

I want to load my_helper.sh
But bats add .bash to forcibly my filename, and then the test failed with error.

Problem

$ cd test/fixtures/bats/
$ echo 'help_me() { true; }' > my_helper.sh
$ HELPER_NAME=my_helper.sh bats load.bats
bats: /path/to/bats/my_helper.sh.bash does not exist

$ # It also fails
$ HELPER_NAME=test_helper.bash bats load.bats
bats: /path/to/bats/test_helper.bash.bash does not exist

Solved

I solved the problem.
If the file exists, bats use it.

$ cd test/fixtures/bats/
$ echo 'help_me() { true; }' > my_helper.sh
$ HELPER_NAME=my_helper.sh bats load.bats
 ✓ calling a loaded helper

1 test, 0 failures

$ HELPER_NAME=test_helper.bash bats load.bats
 ✓ calling a loaded helper

1 test, 0 failures

@ztombol ztombol mentioned this pull request Dec 13, 2016
18 tasks
mjhsieh pushed a commit to mjhsieh/bats that referenced this pull request Mar 20, 2017
- Make `load` handle free filename too sstephenson#147
- Contributed by kawaz
@kawaz kawaz closed this Jul 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant