From 6f3d636f31470790ba1efaa6f040b653fbaee582 Mon Sep 17 00:00:00 2001 From: Mike Peachey Date: Tue, 19 Dec 2023 13:35:06 +0000 Subject: [PATCH 1/2] Replace use of rev for Windows compatibility --- libexec/tfenv-resolve-version | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/tfenv-resolve-version b/libexec/tfenv-resolve-version index d0b66bc..69468e5 100755 --- a/libexec/tfenv-resolve-version +++ b/libexec/tfenv-resolve-version @@ -129,7 +129,7 @@ fi; if [[ "${version_requested}" =~ ^latest-allowed$ ]]; then log 'debug' 'Detecting latest allowable version...'; - version_spec="$(grep -h required_version "${TFENV_DIR:-$(pwd)}"/{*.tf,*.tf.json} 2>/dev/null | rev | cut -d'"' -f2 | rev | cut -d, -f1)"; + version_spec="$(grep -h required_version "${TFENV_DIR:-$(pwd)}"/{*.tf,*.tf.json} 2>/dev/null | { IFS='"' read -r _ ver _; echo "${ver%%,*}"; })"; version_num="$(echo "${version_spec}" | sed -E 's/[^0-9.]+//')"; log 'debug' "Using ${version_num} from version spec: ${version_spec}"; @@ -141,7 +141,7 @@ if [[ "${version_requested}" =~ ^latest-allowed$ ]]; then version_requested="${version_num}"; ;; '~>'*) - version_without_rightmost="$(echo "${version_num}" | rev | cut -d. -f2- | rev)"; + version_without_rightmost="${version_num%.*}"; version_requested="latest:^${version_without_rightmost}"; ;; *) From b9042b0f75012e8a0f55bff883656c8da6eddb66 Mon Sep 17 00:00:00 2001 From: Mike Peachey Date: Tue, 19 Dec 2023 14:20:58 +0000 Subject: [PATCH 2/2] Just suppress darwin tests for unsupported darwin builds --- test/test_install_and_use.sh | 21 +++++++++++++++++++-- test/test_symlink.sh | 12 ++++++------ test/test_use_minrequired.sh | 8 ++++---- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/test/test_install_and_use.sh b/test/test_install_and_use.sh index fd2b6f0..879b62d 100755 --- a/test/test_install_and_use.sh +++ b/test/test_install_and_use.sh @@ -105,11 +105,28 @@ tests__kv=( "$(tfenv list-remote | grep 'rc' | head -n 1),latest:rc" "$(tfenv list-remote | grep '^0\.11\.' | head -n 1),latest:^0.11." '0.11.15-oci,0.11.15-oci' - '0.8.8,latest:^0.8' - '0.7.13,0.7.13' + '1.3.10,latest:^1\.3' + '1.6.3,1.6.3' '0.14.6,v0.14.6' ); +log 'info' "Kernel under test: $(uname -s)"; + +if [[ "$(uname -s)" != Darwin* ]]; then + log 'info' "We're not Darwin! Adding legacy tests."; + tests__desc+=( + 'legacy latest version matching regex' + 'legacy specific version' + ); + + tests__kv+=( + '0.8.8,latest:^0.8' + '0.7.13,0.7.13' + ); +else + log 'warn' "We're Darwin! Skipping legacy tests."; +fi; + tests_count=${#tests__desc[@]}; declare desc kv k v test_num; diff --git a/test/test_symlink.sh b/test/test_symlink.sh index 3c99bfd..5529c9e 100755 --- a/test/test_symlink.sh +++ b/test/test_symlink.sh @@ -60,14 +60,14 @@ ln -s "${PWD}"/bin/* "${TFENV_BIN_DIR}"; cleanup || log 'error' 'Cleanup failed?!'; -log 'info' '## Installing 0.8.2'; -${TFENV_BIN_DIR}/tfenv install 0.8.2 || error_and_proceed 'Install failed'; +log 'info' '## Installing 1.6.1'; +${TFENV_BIN_DIR}/tfenv install 1.6.1 || error_and_proceed 'Install failed'; -log 'info' '## Using 0.8.2'; -${TFENV_BIN_DIR}/tfenv use 0.8.2 || error_and_proceed 'Use failed'; +log 'info' '## Using 1.6.1'; +${TFENV_BIN_DIR}/tfenv use 1.6.1 || error_and_proceed 'Use failed'; -log 'info' '## Check-Version for 0.8.2'; -check_active_version 0.8.2 || error_and_proceed 'Version check failed'; +log 'info' '## Check-Version for 1.6.1'; +check_active_version 1.6.1 || error_and_proceed 'Version check failed'; if [ "${#errors[@]}" -gt 0 ]; then log 'warn' '===== The following symlink tests failed ====='; diff --git a/test/test_use_minrequired.sh b/test/test_use_minrequired.sh index b53b2fa..b915d78 100755 --- a/test/test_use_minrequired.sh +++ b/test/test_use_minrequired.sh @@ -55,7 +55,7 @@ cleanup || log 'error' 'Cleanup failed?!'; log 'info' '### Install min-required normal version (#.#.#)'; -minv='0.8.0'; +minv='1.6.0'; echo "terraform { required_version = \">=${minv}\" @@ -72,7 +72,7 @@ cleanup || log 'error' 'Cleanup failed?!'; log 'info' '### Install min-required tagged version (#.#.#-tag#)' -minv='0.13.0-rc1' +minv='1.5.0-rc1' echo "terraform { required_version = \">=${minv}\" @@ -89,7 +89,7 @@ cleanup || log 'error' 'Cleanup failed?!'; log 'info' '### Install min-required incomplete version (#.#.)' -minv='0.12'; +minv='1.3'; echo "terraform { required_version = \">=${minv}\" @@ -106,7 +106,7 @@ cleanup || log 'error' 'Cleanup failed?!'; log 'info' '### Install min-required with TFENV_AUTO_INSTALL'; -minv='1.0.0'; +minv='1.2.0'; echo "terraform { required_version = \">=${minv}\"