From 5d2e6617790400d6e725fe077a3c531e7fe4411d Mon Sep 17 00:00:00 2001 From: Mark Yen Date: Tue, 6 Feb 2024 17:39:36 -0800 Subject: [PATCH] BATS: Bump submodules Only bats-core has changed; the relevant change is the fix for multiple slashes in the test name for `--gather-test-output-in`. However, the bump also exposed issues where we had unset variables (BAT previous broke usage of `-o nounset`). Signed-off-by: Mark Yen --- .gitmodules | 4 ++++ bats/README.md | 8 ++++++-- bats/bats-core | 2 +- bats/tests/helpers/load.bash | 9 +++++++-- bats/tests/helpers/paths.bash | 4 ++-- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index bf5fc24f743..502378eb405 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,16 @@ [submodule "bats/bats-core"] path = bats/bats-core url = https://github.com/rancher-sandbox/bats-core.git + branch = master [submodule "bats/bats-assert"] path = bats/bats-assert url = https://github.com/rancher-sandbox/bats-assert.git + branch = master [submodule "bats/bats-support"] path = bats/bats-support url = https://github.com/rancher-sandbox/bats-support.git + branch = master [submodule "bats/bats-file"] path = bats/bats-file url = https://github.com/rancher-sandbox/bats-file.git + branch = master diff --git a/bats/README.md b/bats/README.md index 6d502152d3a..968f2107a0c 100644 --- a/bats/README.md +++ b/bats/README.md @@ -63,9 +63,13 @@ To test the Windows-based tools, set `RD_USE_WINDOWS_EXE` to `true` before runni ### RD_LOCATION -By default bats will use Rancher Desktop installed in a "system" location. If that doesn't exists, it will try a "user" location, followed by the local "dist" directory inside the local git directory. The final option if is to use "npm". On Linux there is no "user" location. +By default bats will use Rancher Desktop installed in a "system" location. If +that doesn't exists, it will try a "user" location, followed by the local "dist" +directory inside the local git directory. The final option if none of the above +apply is to use "dev", which uses `npm run dev`. On Linux there is no "user" +location. -You can explicitly request a specific install location by setting `RD_LOCATION` to `system`, `user`, `dist`, or `npm`: +You can explicitly request a specific install location by setting `RD_LOCATION` to `system`, `user`, `dist`, or `dev`: ``` cd bats diff --git a/bats/bats-core b/bats/bats-core index 360c1ea5371..de96df03197 160000 --- a/bats/bats-core +++ b/bats/bats-core @@ -1 +1 @@ -Subproject commit 360c1ea5371622132ab669e9cb9687d21298699b +Subproject commit de96df03197ecc51635463fd9e35e26638191a90 diff --git a/bats/tests/helpers/load.bash b/bats/tests/helpers/load.bash index 929085f6e6b..eab2f921901 100644 --- a/bats/tests/helpers/load.bash +++ b/bats/tests/helpers/load.bash @@ -21,7 +21,12 @@ RD_TEST_FILENAME=${RD_TEST_FILENAME%.bats} # Use fatal() to abort loading helpers; don't run any tests fatal() { - echo " $1" >&3 + # fd 3 might not be open if we're not fully under bats yet; detect that. + if [[ -e /dev/fd/3 ]]; then + echo " $1" >&3 + else + echo " $1" >&2 + fi exit 1 } @@ -88,7 +93,7 @@ teardown_file() { if is_linux || is_windows; then # On Linux & Windows if we don't shutdown Rancher Desktop bats tests don't terminate. shutdown=true - elif [[ $RD_LOCATION == dev ]]; then + elif using_dev_mode; then # In dev mode, we also need to shut down. shutdown=true elif using_ramdisk; then diff --git a/bats/tests/helpers/paths.bash b/bats/tests/helpers/paths.bash index fcf06fb2932..5051f5864be 100644 --- a/bats/tests/helpers/paths.bash +++ b/bats/tests/helpers/paths.bash @@ -12,7 +12,7 @@ set_path_resources() { local dist=$3 local subdir=$4 - if [ -z "$RD_LOCATION" ]; then + if [ -z "${RD_LOCATION:-}" ]; then if [ -d "$system" ]; then RD_LOCATION=system elif [ -d "$user" ]; then @@ -20,7 +20,7 @@ set_path_resources() { elif [ -d "$dist" ]; then RD_LOCATION=dist elif inside_repo_clone; then - RD_LOCATION=npm + RD_LOCATION=dev else ( echo "Couldn't locate Rancher Desktop in"