mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 03:32:27 +01:00
Source all files of a library if no loading file exists
This commit is contained in:
parent
cb434296c5
commit
e96502c7ff
|
@ -52,15 +52,24 @@ load() {
|
||||||
local libpath="${BATS_LIB_PATH:-$HOME/.bats/lib:/usr/lib/bats}"
|
local libpath="${BATS_LIB_PATH:-$HOME/.bats/lib:/usr/lib/bats}"
|
||||||
libpath="$BATS_TEST_DIRNAME:$libpath"
|
libpath="$BATS_TEST_DIRNAME:$libpath"
|
||||||
|
|
||||||
# Test for library file in each libpath, source and return if it
|
# Test for library in each libpath
|
||||||
# exists
|
for libdir in ${libpath//:/ }; do
|
||||||
for part in ${libpath//:/ }; do
|
dirname="$libdir/$name"
|
||||||
filename="$part/$name.bash"
|
filename="$dirname.bash"
|
||||||
|
|
||||||
|
# Test for loading file of library
|
||||||
if [[ -f "$filename" ]]; then
|
if [[ -f "$filename" ]]; then
|
||||||
source "$filename"
|
source "$filename"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Test for library and source all files within
|
||||||
|
if [[ -d "$dirname" ]]; then
|
||||||
|
for libfile in $dirname/*.bash; do
|
||||||
|
source $libfile
|
||||||
|
done
|
||||||
|
return
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "bats: No file $name in BATS_LIB_PATH found" >&2
|
echo "bats: No file $name in BATS_LIB_PATH found" >&2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user