From e96502c7ffa3e6652f9408750b40e002111aa3cc Mon Sep 17 00:00:00 2001 From: Nelo Wallus Date: Wed, 22 Mar 2017 19:49:49 +0100 Subject: [PATCH] Source all files of a library if no loading file exists --- libexec/bats-exec-test | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libexec/bats-exec-test b/libexec/bats-exec-test index f5736f1..b88d460 100755 --- a/libexec/bats-exec-test +++ b/libexec/bats-exec-test @@ -52,15 +52,24 @@ load() { local libpath="${BATS_LIB_PATH:-$HOME/.bats/lib:/usr/lib/bats}" libpath="$BATS_TEST_DIRNAME:$libpath" - # Test for library file in each libpath, source and return if it - # exists - for part in ${libpath//:/ }; do - filename="$part/$name.bash" + # Test for library in each libpath + for libdir in ${libpath//:/ }; do + dirname="$libdir/$name" + filename="$dirname.bash" + # Test for loading file of library if [[ -f "$filename" ]]; then source "$filename" return 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 echo "bats: No file $name in BATS_LIB_PATH found" >&2