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

Fix :latest #2599

Merged
merged 7 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
native-api committed Jan 22, 2023
commit d9309a24bf231ccdde6a39afec6e902d0e6ea3e9
10 changes: 5 additions & 5 deletions plugins/python-build/bin/pyenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ unset VERSION_NAME
# version is specified by pyenv. Show usage instructions if a local
# version is not specified.
DEFINITIONS=("${ARGUMENTS[@]}")
[[ "${#DEFINITIONS[*]}" -eq 0 ] && DEFINITIONS=($(pyenv-local 2>/dev/null || true))
[[ "${#DEFINITIONS[*]}" -eq 0 ] && usage 1 >&2
[[ "${#DEFINITIONS[*]}" -eq 0 ]] && DEFINITIONS=($(pyenv-local 2>/dev/null || true))
[[ "${#DEFINITIONS[*]}" -eq 0 ]] && usage 1 >&2

# Define `before_install` and `after_install` functions that allow
# plugin hooks to register a string of code for execution before or
Expand Down Expand Up @@ -176,7 +176,7 @@ for DEFINITION in "${DEFINITIONS[@]}"; do

case "$REPLY" in
y | Y | yes | YES ) ;;
* ) { STATUS=1; [[ $STATUS -gt $COMBINED_STATUS ]] && COMBINED_STATUS=STATUS; }; continue ;;
* ) { STATUS=1; [[ $STATUS -gt $COMBINED_STATUS ]] && COMBINED_STATUS=$STATUS; }; continue ;;
esac
elif [ -n "$SKIP_EXISTING" ]; then
# Since we know the python version is already installed, and are opting to
Expand Down Expand Up @@ -251,7 +251,7 @@ for DEFINITION in "${DEFINITIONS[@]}"; do

# Invoke `python-build` and record the exit status in $STATUS.
python-build $KEEP $VERBOSE $HAS_PATCH $DEBUG "$DEFINITION" "$PREFIX" || \
{ STATUS="$?"; [[ $STATUS -gt $COMBINED_STATUS ]] && COMBINED_STATUS=STATUS; }
{ STATUS=$?; [[ $STATUS -gt $COMBINED_STATUS ]] && COMBINED_STATUS=$STATUS; }

# Display a more helpful message if the definition wasn't found.
if [ "$STATUS" == "2" ]; then
Expand Down Expand Up @@ -282,7 +282,7 @@ for DEFINITION in "${DEFINITIONS[@]}"; do
for hook in "${after_hooks[@]}"; do eval "$hook"; done

# Run `pyenv-rehash` after a successful installation.
if [ "$STATUS" == "0" ]; then
if [[ $STATUS -eq 0 ]]; then
pyenv-rehash
else
cleanup
Expand Down
7 changes: 3 additions & 4 deletions plugins/python-build/test/pyenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ stub_python_build_lib() {
}

stub_python_build_no_latest() {
stub python_build "${@:-'echo python-build "$@"'}"
stub python-build "${@:-echo python-build \"\$@\"}"
}

stub_python_build() {
Expand Down Expand Up @@ -50,14 +50,11 @@ OUT
@test "install multiple versions, some fail" {
stub_python_build_lib
stub_python_build 'echo "fail: python-build" "$@"; false'
stub_python_build
stub pyenv-latest false false

run pyenv-install 3.4.1 3.4.2
assert_failure
assert_output <<OUT
fail: python-build 3.4.1 ${TMP}/pyenv/versions/3.4.1
python-build 3.4.2 ${TMP}/pyenv/versions/3.4.2
OUT

unstub python-build
Expand Down Expand Up @@ -86,10 +83,12 @@ OUT

@test "install resolves :latest" {
stub_python_build_lib
stub_python_build '--definitions : echo 3.4.2 3.5.1'
stub_python_build
stub pyenv-latest false

run pyenv-install 3.4
unstub python-build
assert_success "python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2"

unstub python-build
Expand Down