From 3031cb97500f96505fbb1b90c64f08330fcca8cc Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Sun, 20 Dec 2015 12:29:30 +0000 Subject: [PATCH] Add workaround for test failure on Arch Linux (#480) --- plugins/python-build/bin/python-build | 45 ++++++++++++++++----------- test/which.bats | 6 ++-- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index d6010de8..a28e6dd9 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1231,8 +1231,31 @@ require_distro() { return 1 } +configured_with_package_dir() { + local package_var_name="$(capitalize "$1")" + shift 1 + local PACKAGE_CONFIGURE_OPTS="${package_var_name}_CONFIGURE_OPTS" + local PACKAGE_CONFIGURE_OPTS_ARRAY="${package_var_name}_MAKE_OPTS_ARRAY[@]" + local arg flag + for arg in ${CONFIGURE_OPTS} ${!PACKAGE_CONFIGURE_OPTS} "${!PACKAGE_CONFIGURE_OPTS_ARRAY}"; do + if [[ "$arg" == "CPPFLAGS="* ]]; then + for flag in ${CPPFLAGS} ${arg##CPPFLAGS=}; do + if [[ "$flag" == "-I"* ]]; then + local header + for header in "$@"; do + if [ -e "${flag##-I}/${header#/}" ]; then + return 0 + fi + done + fi + done + fi + done + return 1 +} + needs_yaml() { - [[ "$RUBY_CONFIGURE_OPTS" != *--with-libyaml-dir=* ]] && + ! configured_with_package_dir "python" "yaml.h" && ! use_homebrew_yaml } @@ -1246,30 +1269,16 @@ use_homebrew_yaml() { fi } -configured_with_readline_dir() { +has_broken_mac_readline() { # Mac OS X 10.4 has broken readline. # https://github.com/yyuu/pyenv/issues/23 - local arg flag - for arg in ${CONFIGURE_OPTS} ${PYTHON_CONFIGURE_OPTS} "${PYTHON_CONFIGURE_OPTS_ARRAY[@]}"; do - if [[ "$arg" == "CPPFLAGS="* ]]; then - for flag in ${CPPFLAGS} ${arg##CPPFLAGS=}; do - if [[ "$flag" == "-I"* ]] && [ -e "${flag##-I}/readline/rlconf.h" ]; then - return 0 - fi - done - fi - done - return 1 -} - -has_broken_mac_readline() { [ "$(uname -s)" = "Darwin" ] && - ! configured_with_readline_dir && + ! configured_with_package_dir "python" "readline/rlconf.h" && ! use_homebrew_readline } use_homebrew_readline() { - if ! configured_with_readline_dir; then + if ! configured_with_package_dir "python" "readline/rlconf.h"; then local libdir="$(brew --prefix readline 2>/dev/null || true)" if [ -d "$libdir" ]; then export CPPFLAGS="-I$libdir/include ${CPPFLAGS}" diff --git a/test/which.bats b/test/which.bats index bd67b4c0..c987573a 100644 --- a/test/which.bats +++ b/test/which.bats @@ -91,9 +91,9 @@ OUT } @test "no executable found for system version" { - export PATH="$(path_without "rake")" - PYENV_VERSION=system run pyenv-which rake - assert_failure "pyenv: rake: command not found" + export PATH="$(path_without "py.test")" + PYENV_VERSION=system run pyenv-which py.test + assert_failure "pyenv: py.test: command not found" } @test "executable found in other versions" {