Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darwin fail #421

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libexec/tfenv-resolve-version
Original file line number Diff line number Diff line change
Expand Up @@ -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}";

Expand All @@ -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}";
;;
*)
Expand Down
21 changes: 19 additions & 2 deletions test/test_install_and_use.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions test/test_symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 =====';
Expand Down
8 changes: 4 additions & 4 deletions test/test_use_minrequired.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"
Expand All @@ -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}\"
Expand All @@ -89,7 +89,7 @@ cleanup || log 'error' 'Cleanup failed?!';

log 'info' '### Install min-required incomplete version (#.#.<missing>)'

minv='0.12';
minv='1.3';

echo "terraform {
required_version = \">=${minv}\"
Expand All @@ -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}\"
Expand Down