Merge pull request #3614 from Andrej730/fix-commands-dylib

Fix broken `pyenv --help` when `.dylib` was compiled
This commit is contained in:
native-api authored and GitHub committed 2026-10-30 03:11:32 +03:00
commit a2d0ea8903
5 files changed
+51 -4

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ jobs:
PYENV_NATIVE_EXT: 1
run: |
(cd src; ./configure; make)
bats/bin/bats test/{pyenv,hooks,versions}.bats
make test
pyenv_tests_docker:
runs-on: ubuntu-latest
steps:
+1
View File
@@ -39,6 +39,7 @@ shopt -s nullglob
else
for path in "${paths[@]}"; do
for command in "${path}"/pyenv-*; do
[[ $command == *.dylib ]] && continue
command="${command##*/pyenv-}"
if [[ -n $nosh ]]; then
if [[ ${command:0:3} != "sh-" ]]; then
+3 -3
View File
@@ -99,7 +99,7 @@ documentation_for() {
print_summary() {
local command="$1"
local summary usage help
local summary="" usage="" help=""
eval "$(documentation_for "$command")"
if [ -n "$summary" ]; then
@@ -115,7 +115,7 @@ print_summaries() {
print_help() {
local command="$1"
local summary usage help
local summary="" usage="" help=""
eval "$(documentation_for "$command")"
[ -n "$help" ] || help="$summary"
@@ -138,7 +138,7 @@ print_help() {
print_usage() {
local command="$1"
local summary usage help
local summary="" usage="" help=""
eval "$(documentation_for "$command")"
[ -z "$usage" ] || echo "$usage"
}
+12
View File
@@ -31,6 +31,18 @@ load test_helper
assert_line "hello"
}
@test "commands excludes .dylib files" {
path="${PYENV_TEST_DIR}/commands"
mkdir -p "$path"
touch "${path}/pyenv-hello" "${path}/pyenv-realpath.dylib"
chmod +x "${path}/pyenv-hello" "${path}/pyenv-realpath.dylib"
PATH="${path}:$PATH" run pyenv-commands
assert_success
assert_line "hello"
refute_line "realpath.dylib"
}
@test "commands --no-sh" {
run pyenv-commands --no-sh
assert_success
+34
View File
@@ -14,6 +14,40 @@ load test_helper
assert_failure "pyenv: no such command \`hello'"
}
@test "summary of commands skips undocumented command" {
mkdir -p "${PYENV_TEST_DIR}/bin"
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
#!shebang
echo hello
SH
run pyenv-help
assert_success
[[ $output != *hello* ]]
}
@test "undocumented command" {
mkdir -p "${PYENV_TEST_DIR}/bin"
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
#!shebang
echo hello
SH
run pyenv-help hello
assert_failure "Sorry, this command isn't documented yet."
}
@test "usage of undocumented command" {
mkdir -p "${PYENV_TEST_DIR}/bin"
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
#!shebang
echo hello
SH
run pyenv-help --usage hello
assert_success ""
}
@test "shows help for a specific command" {
mkdir -p "${PYENV_TEST_DIR}/bin"
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH