Skip to content

Commit

Permalink
Merge pull request #273 from ChronosMasterOfAllTime/no_silent_install…
Browse files Browse the repository at this point in the history
…_failure

Ensure install doesn't exit silently when no installable definition found
  • Loading branch information
ChronosMasterOfAllTime authored Nov 11, 2022
2 parents ab5e09c + 8057712 commit efadea8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugins/go-build/bin/go-build
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ install_bsd_32bit() {
}

install_package_using() {
INSTALL_FOUND=true
local package_type="$1"
local package_type_nargs="$2"
local package_name="$3"
Expand Down Expand Up @@ -914,6 +915,11 @@ unset GOPATH
trap build_failed ERR
mkdir -p "$BUILD_PATH"
# Executes the file and the commands inside
INSTALL_FOUND=false
source "$DEFINITION_PATH"
if [[ $INSTALL_FOUND = false ]]; then
echo "No installable version found for $(uname -s) $(uname -m)"
exit 1
fi
[ -z "${KEEP_BUILD_PATH}" ] && rm -fr "$BUILD_PATH"
trap - ERR
Empty file.
30 changes: 30 additions & 0 deletions plugins/go-build/test/goenv-install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OUT
--verbose
--version
--debug
1.0.0
1.2.0
1.2.2
1.3beta1
Expand Down Expand Up @@ -283,6 +284,7 @@ OUT
assert_success
assert_output <<-OUT
Available versions:
1.0.0
1.2.0
1.2.2
1.3beta1
Expand All @@ -297,6 +299,7 @@ OUT
assert_success
assert_output <<-OUT
Available versions:
1.0.0
1.2.0
1.2.2
1.3beta1
Expand Down Expand Up @@ -415,6 +418,33 @@ OUT
run cat "${GOENV_ROOT}/versions/${LATEST_VERSION}/bin/go"
}

@test "install does not silently fail when no available version to install" {
# NOTE: Create fake definition to install
mkdir -p $GOENV_ROOT/plugins/go-build/share/go-build

LATEST_VERSION=1.0.0

stub goenv-hooks "install : echo '$HOOK_PATH'/install.bash"

export USE_FAKE_DEFINITIONS=true

run goenv-install ${LATEST_VERSION}

unset USE_FAKE_DEFINITIONS

arch=" "
if [ "$(uname -m)" = "aarch64" ]; then
arch=" arm "
fi

assert_output <<-OUT
No installable version found for $(uname -s) $(uname -m)
OUT

assert_failure
}

@test "{before,after}_install hooks get triggered when '--force' argument and version argument is not already installed version and gets installed" {
create_hook install hello.bash <<SH
before_install 'echo before: \$PREFIX'
Expand Down

0 comments on commit efadea8

Please sign in to comment.