mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
Merge pull request #2073 from native-api/github_actions_tests
GitHub actions tests
This commit is contained in:
commit
0211c345f7
12 changed files with 112 additions and 60 deletions
35
.github/workflows/pyenv_tests.yml
vendored
Normal file
35
.github/workflows/pyenv_tests.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
name: pyenv_tests
|
||||||
|
on: [pull_request, push]
|
||||||
|
jobs:
|
||||||
|
pyenv_tests:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-20.04
|
||||||
|
- ubuntu-18.04
|
||||||
|
- macos-11
|
||||||
|
- macos-10.15
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
# Normally, we would use the superbly maintained...
|
||||||
|
# - uses: actions/setup-python@v2
|
||||||
|
# with:
|
||||||
|
# python-version: ${{ matrix.python-version }}
|
||||||
|
# ... but in the repo, we want to test pyenv builds on Ubuntu
|
||||||
|
# - run: |
|
||||||
|
# sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
|
||||||
|
# libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
|
||||||
|
# xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
|
||||||
|
# https://github.com/pyenv/pyenv#installation
|
||||||
|
- run: |
|
||||||
|
if test "$RUNNER_OS" == "macOS"; then brew install coreutils; fi
|
||||||
|
- run: pwd
|
||||||
|
- env:
|
||||||
|
PYENV_ROOT: /home/runner/work/pyenv/pyenv
|
||||||
|
run: |
|
||||||
|
echo $PYENV_ROOT
|
||||||
|
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
||||||
|
- run: |
|
||||||
|
make test
|
|
@ -44,8 +44,9 @@ extract_initial_comment_block() {
|
||||||
}
|
}
|
||||||
|
|
||||||
collect_documentation() {
|
collect_documentation() {
|
||||||
# shellcheck disable=SC2016
|
# `tail` prevents "broken pipe" errors due to `head` closing thge pipe without reading everything
|
||||||
$(type -P gawk awk | head -1) '
|
# https://superuser.com/questions/554855/how-can-i-fix-a-broken-pipe-error/642932#642932
|
||||||
|
$(type -P gawk awk | tail -n +1 | head -1) '
|
||||||
/^Summary:/ {
|
/^Summary:/ {
|
||||||
summary = substr($0, 10)
|
summary = substr($0, 10)
|
||||||
next
|
next
|
||||||
|
|
|
@ -160,17 +160,15 @@ OUT
|
||||||
brew_libdir="$TMP/homebrew-yaml"
|
brew_libdir="$TMP/homebrew-yaml"
|
||||||
mkdir -p "$brew_libdir"
|
mkdir -p "$brew_libdir"
|
||||||
|
|
||||||
# pyenv/pyenv#1026
|
for i in {1..4}; do stub uname '-s : echo Darwin'; done
|
||||||
stub uname false false
|
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
|
||||||
|
|
||||||
stub uname '-s : echo Linux'
|
|
||||||
stub uname '-s : echo Darwin'
|
|
||||||
stub brew "--prefix libyaml : echo '$brew_libdir'" false false
|
stub brew "--prefix libyaml : echo '$brew_libdir'" false false
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
|
||||||
install_fixture definitions/needs-yaml
|
install_fixture definitions/needs-yaml
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
|
unstub sw_vers
|
||||||
unstub uname
|
unstub uname
|
||||||
unstub brew
|
unstub brew
|
||||||
unstub make
|
unstub make
|
||||||
|
|
|
@ -63,13 +63,9 @@ DEF
|
||||||
mkdir -p "$INSTALL_ROOT"
|
mkdir -p "$INSTALL_ROOT"
|
||||||
cd "$INSTALL_ROOT"
|
cd "$INSTALL_ROOT"
|
||||||
|
|
||||||
# pyenv/pyenv#1026
|
for i in {1..5}; do stub uname '-s : echo Darwin'; done
|
||||||
stub uname false '-s : echo Darwin' false '-s : echo Darwin' '-s : echo Darwin'
|
for i in {1..4}; do stub sw_vers '-productVersion : echo 10.10'; done
|
||||||
stub sw_vers '-productVersion : echo 10.10'
|
|
||||||
|
|
||||||
stub sw_vers '-productVersion : echo 10.10'
|
|
||||||
stub sw_vers '-productVersion : echo 10.10'
|
|
||||||
stub sw_vers '-productVersion : echo 10.10'
|
|
||||||
stub cc 'false'
|
stub cc 'false'
|
||||||
stub brew 'false'
|
stub brew 'false'
|
||||||
stub make \
|
stub make \
|
||||||
|
|
|
@ -136,7 +136,7 @@ OUT
|
||||||
@test "apply built-in python patches should be sorted by its name" {
|
@test "apply built-in python patches should be sorted by its name" {
|
||||||
cached_tarball "Python-3.6.2"
|
cached_tarball "Python-3.6.2"
|
||||||
|
|
||||||
stub brew false
|
for i in {1..2}; do stub brew '* : false'; done
|
||||||
stub_make_install
|
stub_make_install
|
||||||
stub patch ' : for arg; do [[ "$arg" == "-"* ]] || sed -e "s/^/patch: /" "$arg"; done >> build.log'
|
stub patch ' : for arg; do [[ "$arg" == "-"* ]] || sed -e "s/^/patch: /" "$arg"; done >> build.log'
|
||||||
|
|
||||||
|
@ -144,9 +144,7 @@ OUT
|
||||||
echo "bar" | install_patch definitions/vanilla-python "Python-3.6.2/bar.patch"
|
echo "bar" | install_patch definitions/vanilla-python "Python-3.6.2/bar.patch"
|
||||||
echo "baz" | install_patch definitions/vanilla-python "Python-3.6.2/baz.patch"
|
echo "baz" | install_patch definitions/vanilla-python "Python-3.6.2/baz.patch"
|
||||||
|
|
||||||
# yyuu/pyenv#257
|
for i in {1..2}; do stub uname '-s : echo Linux'; done
|
||||||
stub uname '-s : echo Linux'
|
|
||||||
stub uname '-s : echo Linux'
|
|
||||||
|
|
||||||
TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
|
TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||||
assert_success
|
assert_success
|
||||||
|
@ -173,9 +171,7 @@ OUT
|
||||||
" : echo \"$MAKE \$@\" >> build.log" \
|
" : echo \"$MAKE \$@\" >> build.log" \
|
||||||
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
||||||
|
|
||||||
# yyuu/pyenv#257
|
for i in {1..4}; do stub uname '-s : echo Darwin'; done
|
||||||
stub uname '-s : echo Linux'
|
|
||||||
stub uname '-s : echo Linux'
|
|
||||||
|
|
||||||
PYTHON_MAKE_INSTALL_TARGET="altinstall" TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
|
PYTHON_MAKE_INSTALL_TARGET="altinstall" TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||||
assert_success
|
assert_success
|
||||||
|
@ -259,10 +255,7 @@ OUT
|
||||||
touch "${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin/python3.4-config"
|
touch "${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin/python3.4-config"
|
||||||
chmod +x "${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin/python3.4-config"
|
chmod +x "${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin/python3.4-config"
|
||||||
|
|
||||||
# yyuu/pyenv#257
|
for i in {1..3}; do stub uname '-s : echo Darwin'; done
|
||||||
stub uname '-s : echo Darwin'
|
|
||||||
|
|
||||||
stub uname '-s : echo Darwin'
|
|
||||||
|
|
||||||
PYTHON_CONFIGURE_OPTS="--enable-framework" TMPDIR="$TMP" run_inline_definition <<OUT
|
PYTHON_CONFIGURE_OPTS="--enable-framework" TMPDIR="$TMP" run_inline_definition <<OUT
|
||||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||||
|
@ -278,10 +271,8 @@ EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "enable universalsdk" {
|
@test "enable universalsdk" {
|
||||||
# yyuu/pyenv#257
|
|
||||||
stub uname '-s : echo Darwin'
|
for i in {1..3}; do stub uname '-s : echo Darwin'; done
|
||||||
|
|
||||||
stub uname '-s : echo Darwin'
|
|
||||||
|
|
||||||
PYTHON_CONFIGURE_OPTS="--enable-universalsdk" TMPDIR="$TMP" run_inline_definition <<OUT
|
PYTHON_CONFIGURE_OPTS="--enable-universalsdk" TMPDIR="$TMP" run_inline_definition <<OUT
|
||||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||||
|
@ -295,7 +286,8 @@ EOS
|
||||||
@test "enable custom unicode configuration" {
|
@test "enable custom unicode configuration" {
|
||||||
cached_tarball "Python-3.6.2"
|
cached_tarball "Python-3.6.2"
|
||||||
|
|
||||||
stub brew false
|
for i in {1..2}; do stub brew '* : false'; done
|
||||||
|
for i in {1..3}; do stub uname '-s : echo Linux'; done
|
||||||
stub "$MAKE" \
|
stub "$MAKE" \
|
||||||
" : echo \"$MAKE \$@\" >> build.log" \
|
" : echo \"$MAKE \$@\" >> build.log" \
|
||||||
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
||||||
|
@ -311,6 +303,8 @@ make install
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
unstub make
|
unstub make
|
||||||
|
unstub uname
|
||||||
|
unstub brew
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "default MACOSX_DEPLOYMENT_TARGET" {
|
@test "default MACOSX_DEPLOYMENT_TARGET" {
|
||||||
|
|
|
@ -11,11 +11,10 @@ _STUB_RUN="${PROGRAM}_STUB_RUN"
|
||||||
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
||||||
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
||||||
_STUB_END="${PROGRAM}_STUB_END"
|
_STUB_END="${PROGRAM}_STUB_END"
|
||||||
_STUB_DEBUG="${PROGRAM}_STUB_DEBUG"
|
_STUB_LOG="${PROGRAM}_STUB_LOG"
|
||||||
|
|
||||||
if [ -n "${!_STUB_DEBUG}" ]; then
|
[ -n "${!_STUB_LOG}" ] || eval "${_STUB_LOG}"="${TMPDIR}/${program}-stub-log"
|
||||||
echo "$program" "$@" >&${!_STUB_DEBUG}
|
if test -z "${!_STUB_END}"; then echo "$program" "$@" >>"${!_STUB_LOG}"; fi
|
||||||
fi
|
|
||||||
|
|
||||||
[ -e "${!_STUB_PLAN}" ] || exit 1
|
[ -e "${!_STUB_PLAN}" ] || exit 1
|
||||||
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${TMPDIR}/${program}-stub-run"
|
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${TMPDIR}/${program}-stub-run"
|
||||||
|
@ -24,7 +23,7 @@ fi
|
||||||
# Initialize or load the stub run information.
|
# Initialize or load the stub run information.
|
||||||
eval "${_STUB_INDEX}"=1
|
eval "${_STUB_INDEX}"=1
|
||||||
eval "${_STUB_RESULT}"=0
|
eval "${_STUB_RESULT}"=0
|
||||||
[ ! -e "${!_STUB_RUN}" ] || source "${!_STUB_RUN}"
|
if test -e "${!_STUB_RUN}"; then source "${!_STUB_RUN}"; fi
|
||||||
|
|
||||||
|
|
||||||
# Loop over each line in the plan.
|
# Loop over each line in the plan.
|
||||||
|
@ -80,14 +79,39 @@ done < "${!_STUB_PLAN}"
|
||||||
|
|
||||||
|
|
||||||
if [ -n "${!_STUB_END}" ]; then
|
if [ -n "${!_STUB_END}" ]; then
|
||||||
# Clean up the run file.
|
|
||||||
rm -f "${!_STUB_RUN}"
|
|
||||||
|
|
||||||
# If the number of lines in the plan is larger than
|
# If the number of lines in the plan is larger than
|
||||||
# the requested index, we failed.
|
# the requested index, we failed.
|
||||||
if [ $index -ge "${!_STUB_INDEX}" ]; then
|
if [ $index -ge "${!_STUB_INDEX}" ]; then
|
||||||
eval "${_STUB_RESULT}"=1
|
eval "${_STUB_RESULT}"=1
|
||||||
|
{
|
||||||
|
echo "index: $index; stub index: ${!_STUB_INDEX}"
|
||||||
|
echo "plan:"
|
||||||
|
cat "${!_STUB_PLAN}"
|
||||||
|
echo "run:"
|
||||||
|
cat "${!_STUB_RUN}"
|
||||||
|
echo "log:"
|
||||||
|
cat "${!_STUB_LOG}"
|
||||||
|
} >&2
|
||||||
fi
|
fi
|
||||||
|
if [ "${!_STUB_RESULT}" -ne 0 ]; then
|
||||||
|
{
|
||||||
|
echo "index: $index; stub index: ${!_STUB_INDEX}"
|
||||||
|
echo "plan:"
|
||||||
|
cat "${!_STUB_PLAN}" || true
|
||||||
|
echo "run:"
|
||||||
|
cat "${!_STUB_RUN}" || true
|
||||||
|
echo "log:"
|
||||||
|
cat "${!_STUB_LOG}" || true
|
||||||
|
} >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up the run file.
|
||||||
|
rm -f "${!_STUB_RUN}"
|
||||||
|
rm -f "${!_STUB_LOG}"
|
||||||
|
|
||||||
|
# Clean up the run file.
|
||||||
|
rm -f "${!_STUB_RUN}"
|
||||||
|
rm -f "${!_STUB_LOG}"
|
||||||
|
|
||||||
# Return the result.
|
# Return the result.
|
||||||
exit "${!_STUB_RESULT}"
|
exit "${!_STUB_RESULT}"
|
||||||
|
|
|
@ -25,6 +25,7 @@ stub() {
|
||||||
|
|
||||||
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
|
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
|
||||||
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
|
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
|
||||||
|
export "${prefix}_STUB_LOG"="${TMP}/${program}-stub-log"
|
||||||
export "${prefix}_STUB_END"=
|
export "${prefix}_STUB_END"=
|
||||||
|
|
||||||
mkdir -p "${TMP}/bin"
|
mkdir -p "${TMP}/bin"
|
||||||
|
|
|
@ -32,8 +32,7 @@ static_version="$(grep VERSION "$bats_bin" | head -1 | cut -d'"' -f 2)"
|
||||||
|
|
||||||
@test "git remote doesn't match" {
|
@test "git remote doesn't match" {
|
||||||
stub git \
|
stub git \
|
||||||
'remote -v : echo origin https://github.com/Homebrew/homebrew.git' \
|
'remote -v : echo origin https://github.com/Homebrew/homebrew.git'
|
||||||
"describe --tags HEAD : echo v1984-12-gSHA"
|
|
||||||
run python-build --version
|
run python-build --version
|
||||||
assert_success "python-build ${static_version}"
|
assert_success "python-build ${static_version}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "sys.executable with system version (#98)" {
|
@test "sys.executable with system version (#98)" {
|
||||||
system_python=$(which python3)
|
system_python="$(python3 -c 'import sys; print(sys.executable)')"
|
||||||
|
|
||||||
PYENV_VERSION="custom"
|
PYENV_VERSION="custom"
|
||||||
create_executable "python3" ""
|
create_executable "python3" ""
|
||||||
|
|
|
@ -25,7 +25,7 @@ load test_helper
|
||||||
}
|
}
|
||||||
|
|
||||||
#Arch has Python at sbin as well as bin
|
#Arch has Python at sbin as well as bin
|
||||||
@test "prefix for sbin system" {
|
@test "prefix for system in sbin" {
|
||||||
mkdir -p "${PYENV_TEST_DIR}/sbin"
|
mkdir -p "${PYENV_TEST_DIR}/sbin"
|
||||||
touch "${PYENV_TEST_DIR}/sbin/python"
|
touch "${PYENV_TEST_DIR}/sbin/python"
|
||||||
chmod +x "${PYENV_TEST_DIR}/sbin/python"
|
chmod +x "${PYENV_TEST_DIR}/sbin/python"
|
||||||
|
@ -46,6 +46,6 @@ OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "prefix for invalid system" {
|
@test "prefix for invalid system" {
|
||||||
PATH="$(path_without python)" run pyenv-prefix system
|
PATH="$(path_without python python2 python3)" run pyenv-prefix system
|
||||||
assert_failure "pyenv: system version not found in PATH"
|
assert_failure "pyenv: system version not found in PATH"
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ flunk() {
|
||||||
|
|
||||||
assert_success() {
|
assert_success() {
|
||||||
if [ "$status" -ne 0 ]; then
|
if [ "$status" -ne 0 ]; then
|
||||||
flunk "command failed with exit status $status"
|
flunk "command failed with exit status $status" $'\n'\
|
||||||
|
"output: $output"
|
||||||
elif [ "$#" -gt 0 ]; then
|
elif [ "$#" -gt 0 ]; then
|
||||||
assert_output "$1"
|
assert_output "$1"
|
||||||
fi
|
fi
|
||||||
|
@ -52,7 +53,8 @@ assert_success() {
|
||||||
|
|
||||||
assert_failure() {
|
assert_failure() {
|
||||||
if [ "$status" -eq 0 ]; then
|
if [ "$status" -eq 0 ]; then
|
||||||
flunk "expected failed exit status"
|
flunk "expected failed exit status" $'\n'\
|
||||||
|
"output: $output"
|
||||||
elif [ "$#" -gt 0 ]; then
|
elif [ "$#" -gt 0 ]; then
|
||||||
assert_output "$1"
|
assert_output "$1"
|
||||||
fi
|
fi
|
||||||
|
@ -111,24 +113,26 @@ assert() {
|
||||||
# Output a modified PATH that ensures that the given executable is not present,
|
# Output a modified PATH that ensures that the given executable is not present,
|
||||||
# but in which system utils necessary for pyenv operation are still available.
|
# but in which system utils necessary for pyenv operation are still available.
|
||||||
path_without() {
|
path_without() {
|
||||||
local exe="$1"
|
|
||||||
local path=":${PATH}:"
|
local path=":${PATH}:"
|
||||||
local found alt util
|
for exe; do
|
||||||
for found in $(which -a "$exe"); do
|
local found alt util
|
||||||
found="${found%/*}"
|
for found in $(PATH="$path" which -a "$exe"); do
|
||||||
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
|
found="${found%/*}"
|
||||||
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
|
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
|
||||||
mkdir -p "$alt"
|
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
|
||||||
for util in bash head cut readlink greadlink; do
|
mkdir -p "$alt"
|
||||||
if [ -x "${found}/$util" ]; then
|
for util in bash head cut readlink greadlink which; do
|
||||||
ln -s "${found}/$util" "${alt}/$util"
|
if [ -x "${found}/$util" ]; then
|
||||||
fi
|
ln -s "${found}/$util" "${alt}/$util"
|
||||||
done
|
fi
|
||||||
path="${path/:${found}:/:${alt}:}"
|
done
|
||||||
fi
|
path="${path/:${found}:/:${alt}:}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
path="${path#:}"
|
path="${path#:}"
|
||||||
echo "${path%:}"
|
path="${path%:}"
|
||||||
|
echo "$path"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_hook() {
|
create_hook() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ stub_system_python() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "not even system python available" {
|
@test "not even system python available" {
|
||||||
PATH="$(path_without python)" run pyenv-versions
|
PATH="$(path_without python python2 python3)" run pyenv-versions
|
||||||
assert_failure
|
assert_failure
|
||||||
assert_output "Warning: no Python detected on the system"
|
assert_output "Warning: no Python detected on the system"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue