From 70cd52aba4619e0063951148ca451e5a10b3bdeb Mon Sep 17 00:00:00 2001 From: Ryan Schumacher Date: Fri, 23 Aug 2024 10:03:15 -0500 Subject: [PATCH] add bats lib --- .github/workflows/ci.yaml | 2 ++ tests/profile.bats | 29 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3bff8878..64cd6496 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,6 +51,8 @@ jobs: end-to-end: name: e2e tests runs-on: ubuntu-22.04 + env: + BATS_LIB_PATH: /usr/lib steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: Check out platform diff --git a/tests/profile.bats b/tests/profile.bats index c680870e..58d7204c 100755 --- a/tests/profile.bats +++ b/tests/profile.bats @@ -5,20 +5,25 @@ setup() { OTDFCTL_BIN=./otdfctl_testbuild - # Check if BATS_SUPPORT_PATH environment variable exists - if [ -z "${BATS_SUPPORT_PATH}" ]; then - # Check if bats is installed via homebrew - if [[ $(which bats) == *"/homebrew/"* ]]; then - FINAL_BATS_SUPPORT_PATH=$(brew --prefix)/lib - else - FINAL_BATS_SUPPORT_PATH=$(dirname $(which bats))/../lib + if [[ $(which bats) == *"homebrew"* ]]; then + BATS_LIB_PATH=$(brew --prefix)/lib + fi + + # Check if BATS_LIB_PATH environment variable exists + if [ -z "${BATS_LIB_PATH}" ]; then + # Check if bats bin has homebrew in path name + if [[ $(which bats) == *"homebrew"* ]]; then + BATS_LIB_PATH=$(dirname $(which bats))/../lib + elif [ -d "/usr/lib/bats-support" ]; then + BATS_LIB_PATH="/usr/lib" + elif [ -d "/usr/local/lib/bats-support" ]; then + # Check if bats-support exists in /usr/local/lib + BATS_LIB_PATH="/usr/local/lib" fi - else - FINAL_BATS_SUPPORT_PATH="${BATS_SUPPORT_PATH}" fi - echo "FINAL_BATS_SUPPORT_PATH: $FINAL_BATS_SUPPORT_PATH" - load "${FINAL_BATS_SUPPORT_PATH}/bats-support/load.bash" - load "${FINAL_BATS_SUPPORT_PATH}/bats-assert/load.bash" + echo "BATS_LIB_PATH: $BATS_LIB_PATH" + load "${BATS_LIB_PATH}/bats-support/load.bash" + load "${BATS_LIB_PATH}/bats-assert/load.bash" set_test_profile() { auth=""