From 0f288f2462908f2d5b5acbb72c925d49451fa7ba Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Tue, 25 Aug 2015 15:37:31 +0900 Subject: [PATCH] Import changes from ruby-build v20150818 --- plugins/python-build/bin/pyenv-install | 3 +-- plugins/python-build/bin/pyenv-uninstall | 3 +-- plugins/python-build/bin/python-build | 32 ++++++++++++++++++------ plugins/python-build/test/arguments.bats | 2 +- plugins/python-build/test/pyenv.bats | 30 +++++++++++++++++++--- 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/plugins/python-build/bin/pyenv-install b/plugins/python-build/bin/pyenv-install index c0f8a86d..c1a344c4 100755 --- a/plugins/python-build/bin/pyenv-install +++ b/plugins/python-build/bin/pyenv-install @@ -47,8 +47,7 @@ fi eval "$(python-build --lib)" usage() { - # We can remove the sed fallback once pyenv 0.4.0 is widely available. - pyenv-help install 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0" + pyenv-help install 2>/dev/null [ -z "$1" ] || exit "$1" } diff --git a/plugins/python-build/bin/pyenv-uninstall b/plugins/python-build/bin/pyenv-uninstall index ed6a3b84..770cea82 100755 --- a/plugins/python-build/bin/pyenv-uninstall +++ b/plugins/python-build/bin/pyenv-uninstall @@ -18,8 +18,7 @@ if [ "$1" = "--complete" ]; then fi usage() { - # We can remove the sed fallback once pyenv 0.4.0 is widely available - pyenv-help uninstall 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0" + pyenv-help uninstall 2>/dev/null [ -z "$1" ] || exit "$1" } diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 1ae492eb..25b023ff 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -12,7 +12,7 @@ # -g/--debug Build a debug version # -PYTHON_BUILD_VERSION="20150519" +PYTHON_BUILD_VERSION="20150818" set -E exec 3<&2 # preserve original stderr at fd 3 @@ -1132,12 +1132,13 @@ require_llvm() { local llvm_version="$1" if [ "$(uname -s)" = "Darwin" ] && [ "$(osx_version)" -ge 1010 ]; then if [[ "$PYTHON_CONFIGURE_OPTS" != *--llvm-* ]]; then - if [ "$llvm_version" = "3.2" ]; then + case "$llvm_version" in + 3.2 ) package_option python configure --prebuilt-name="llvm-3.2-x86_64-apple-darwin13.tar.bz2" - else - local llvm_prefix="$(brew --prefix llvm 2>/dev/null || true)" - local llvm_config="${llvm_prefix}/bin/llvm-config" - if [ -x "$llvm_config" ]; then + ;; + 3.5 ) + local llvm_config="$(locate_llvm "$llvm_version")" + if [ -n "$llvm_config" ]; then package_option python configure --llvm-config="$llvm_config" else { echo @@ -1148,16 +1149,31 @@ require_llvm() { colorize 1 "TO FIX THE PROBLEM" echo ": Install Homebrew's llvm package with this" echo -n "command: " - colorize 4 "brew install llvm" + colorize 4 "brew tap homebrew/versions ; brew install llvm35" echo } >&3 return 1 fi - fi + ;; + esac fi fi } +locate_llvm() { + local llvm_version="$1" + local package llvm_config + shopt -s nullglob + for package in `brew list 2>/dev/null | grep "^llvm"`; do + llvm_config="$(echo "$(brew --prefix "$package")/bin/llvm-config"*)" + if [ -n "$llvm_config" ] && [[ "$("$llvm_config" --version)" = "$llvm_version"* ]]; then + echo "$llvm_config" + break + fi + done + shopt -u nullglob +} + require_java() { local java="$(command -v java || true)" diff --git a/plugins/python-build/test/arguments.bats b/plugins/python-build/test/arguments.bats index 56840b65..965e5e43 100644 --- a/plugins/python-build/test/arguments.bats +++ b/plugins/python-build/test/arguments.bats @@ -2,7 +2,7 @@ load test_helper -@test "not enought arguments for python-build" { +@test "not enough arguments for python-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" diff --git a/plugins/python-build/test/pyenv.bats b/plugins/python-build/test/pyenv.bats index 577b2a30..2c14e5ae 100644 --- a/plugins/python-build/test/pyenv.bats +++ b/plugins/python-build/test/pyenv.bats @@ -149,39 +149,61 @@ OUT @test "not enough arguments for pyenv-install" { stub_python_build + stub pyenv-help 'install : true' + run pyenv-install assert_failure - assert_output_contains 'Usage: pyenv install' + unstub pyenv-help } @test "too many arguments for pyenv-install" { stub_python_build + stub pyenv-help 'install : true' + run pyenv-install 3.4.1 3.4.2 assert_failure - assert_output_contains 'Usage: pyenv install' + unstub pyenv-help } @test "show help for pyenv-install" { stub_python_build + stub pyenv-help 'install : true' + run pyenv-install -h assert_success + unstub pyenv-help +} + +@test "pyenv-install has usage help preface" { + run head "$(which pyenv-install)" assert_output_contains 'Usage: pyenv install' } @test "not enough arguments pyenv-uninstall" { + stub pyenv-help 'uninstall : true' + run pyenv-uninstall assert_failure - assert_output_contains 'Usage: pyenv uninstall' + unstub pyenv-help } @test "too many arguments for pyenv-uninstall" { + stub pyenv-help 'uninstall : true' + run pyenv-uninstall 3.4.1 3.4.2 assert_failure - assert_output_contains 'Usage: pyenv uninstall' + unstub pyenv-help } @test "show help for pyenv-uninstall" { + stub pyenv-help 'uninstall : true' + run pyenv-uninstall -h assert_success + unstub pyenv-help +} + +@test "pyenv-uninstall has usage help preface" { + run head "$(which pyenv-uninstall)" assert_output_contains 'Usage: pyenv uninstall' }