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() {
|
||||
# shellcheck disable=SC2016
|
||||
$(type -P gawk awk | head -1) '
|
||||
# `tail` prevents "broken pipe" errors due to `head` closing thge pipe without reading everything
|
||||
# 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 = substr($0, 10)
|
||||
next
|
||||
|
|
|
@ -160,17 +160,15 @@ OUT
|
|||
brew_libdir="$TMP/homebrew-yaml"
|
||||
mkdir -p "$brew_libdir"
|
||||
|
||||
# pyenv/pyenv#1026
|
||||
stub uname false false
|
||||
|
||||
stub uname '-s : echo Linux'
|
||||
stub uname '-s : echo Darwin'
|
||||
for i in {1..4}; do stub uname '-s : echo Darwin'; done
|
||||
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
|
||||
stub brew "--prefix libyaml : echo '$brew_libdir'" false false
|
||||
stub_make_install
|
||||
|
||||
install_fixture definitions/needs-yaml
|
||||
assert_success
|
||||
|
||||
unstub sw_vers
|
||||
unstub uname
|
||||
unstub brew
|
||||
unstub make
|
||||
|
|
|
@ -63,13 +63,9 @@ DEF
|
|||
mkdir -p "$INSTALL_ROOT"
|
||||
cd "$INSTALL_ROOT"
|
||||
|
||||
# pyenv/pyenv#1026
|
||||
stub uname false '-s : echo Darwin' false '-s : echo Darwin' '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.10'
|
||||
for i in {1..5}; do stub uname '-s : echo Darwin'; done
|
||||
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 cc 'false'
|
||||
stub brew 'false'
|
||||
stub make \
|
||||
|
|
|
@ -136,7 +136,7 @@ OUT
|
|||
@test "apply built-in python patches should be sorted by its name" {
|
||||
cached_tarball "Python-3.6.2"
|
||||
|
||||
stub brew false
|
||||
for i in {1..2}; do stub brew '* : false'; done
|
||||
stub_make_install
|
||||
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 "baz" | install_patch definitions/vanilla-python "Python-3.6.2/baz.patch"
|
||||
|
||||
# yyuu/pyenv#257
|
||||
stub uname '-s : echo Linux'
|
||||
stub uname '-s : echo Linux'
|
||||
for i in {1..2}; do stub uname '-s : echo Linux'; done
|
||||
|
||||
TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||
assert_success
|
||||
|
@ -173,9 +171,7 @@ OUT
|
|||
" : echo \"$MAKE \$@\" >> build.log" \
|
||||
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
||||
|
||||
# yyuu/pyenv#257
|
||||
stub uname '-s : echo Linux'
|
||||
stub uname '-s : echo Linux'
|
||||
for i in {1..4}; do stub uname '-s : echo Darwin'; done
|
||||
|
||||
PYTHON_MAKE_INSTALL_TARGET="altinstall" TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||
assert_success
|
||||
|
@ -259,10 +255,7 @@ OUT
|
|||
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"
|
||||
|
||||
# yyuu/pyenv#257
|
||||
stub uname '-s : echo Darwin'
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
for i in {1..3}; do stub uname '-s : echo Darwin'; done
|
||||
|
||||
PYTHON_CONFIGURE_OPTS="--enable-framework" TMPDIR="$TMP" run_inline_definition <<OUT
|
||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||
|
@ -278,10 +271,8 @@ EOS
|
|||
}
|
||||
|
||||
@test "enable universalsdk" {
|
||||
# yyuu/pyenv#257
|
||||
stub uname '-s : echo Darwin'
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
for i in {1..3}; do stub uname '-s : echo Darwin'; done
|
||||
|
||||
PYTHON_CONFIGURE_OPTS="--enable-universalsdk" TMPDIR="$TMP" run_inline_definition <<OUT
|
||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||
|
@ -295,7 +286,8 @@ EOS
|
|||
@test "enable custom unicode configuration" {
|
||||
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" \
|
||||
" : echo \"$MAKE \$@\" >> build.log" \
|
||||
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
||||
|
@ -311,6 +303,8 @@ make install
|
|||
OUT
|
||||
|
||||
unstub make
|
||||
unstub uname
|
||||
unstub brew
|
||||
}
|
||||
|
||||
@test "default MACOSX_DEPLOYMENT_TARGET" {
|
||||
|
|
|
@ -11,11 +11,10 @@ _STUB_RUN="${PROGRAM}_STUB_RUN"
|
|||
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
||||
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
||||
_STUB_END="${PROGRAM}_STUB_END"
|
||||
_STUB_DEBUG="${PROGRAM}_STUB_DEBUG"
|
||||
_STUB_LOG="${PROGRAM}_STUB_LOG"
|
||||
|
||||
if [ -n "${!_STUB_DEBUG}" ]; then
|
||||
echo "$program" "$@" >&${!_STUB_DEBUG}
|
||||
fi
|
||||
[ -n "${!_STUB_LOG}" ] || eval "${_STUB_LOG}"="${TMPDIR}/${program}-stub-log"
|
||||
if test -z "${!_STUB_END}"; then echo "$program" "$@" >>"${!_STUB_LOG}"; fi
|
||||
|
||||
[ -e "${!_STUB_PLAN}" ] || exit 1
|
||||
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${TMPDIR}/${program}-stub-run"
|
||||
|
@ -24,7 +23,7 @@ fi
|
|||
# Initialize or load the stub run information.
|
||||
eval "${_STUB_INDEX}"=1
|
||||
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.
|
||||
|
@ -80,14 +79,39 @@ done < "${!_STUB_PLAN}"
|
|||
|
||||
|
||||
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
|
||||
# the requested index, we failed.
|
||||
if [ $index -ge "${!_STUB_INDEX}" ]; then
|
||||
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
|
||||
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.
|
||||
exit "${!_STUB_RESULT}"
|
||||
|
|
|
@ -25,6 +25,7 @@ stub() {
|
|||
|
||||
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
|
||||
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
|
||||
export "${prefix}_STUB_LOG"="${TMP}/${program}-stub-log"
|
||||
export "${prefix}_STUB_END"=
|
||||
|
||||
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" {
|
||||
stub git \
|
||||
'remote -v : echo origin https://github.com/Homebrew/homebrew.git' \
|
||||
"describe --tags HEAD : echo v1984-12-gSHA"
|
||||
'remote -v : echo origin https://github.com/Homebrew/homebrew.git'
|
||||
run python-build --version
|
||||
assert_success "python-build ${static_version}"
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ OUT
|
|||
}
|
||||
|
||||
@test "sys.executable with system version (#98)" {
|
||||
system_python=$(which python3)
|
||||
system_python="$(python3 -c 'import sys; print(sys.executable)')"
|
||||
|
||||
PYENV_VERSION="custom"
|
||||
create_executable "python3" ""
|
||||
|
|
|
@ -25,7 +25,7 @@ load test_helper
|
|||
}
|
||||
|
||||
#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"
|
||||
touch "${PYENV_TEST_DIR}/sbin/python"
|
||||
chmod +x "${PYENV_TEST_DIR}/sbin/python"
|
||||
|
@ -46,6 +46,6 @@ OUT
|
|||
}
|
||||
|
||||
@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"
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ flunk() {
|
|||
|
||||
assert_success() {
|
||||
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
|
||||
assert_output "$1"
|
||||
fi
|
||||
|
@ -52,7 +53,8 @@ assert_success() {
|
|||
|
||||
assert_failure() {
|
||||
if [ "$status" -eq 0 ]; then
|
||||
flunk "expected failed exit status"
|
||||
flunk "expected failed exit status" $'\n'\
|
||||
"output: $output"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
assert_output "$1"
|
||||
fi
|
||||
|
@ -111,15 +113,15 @@ assert() {
|
|||
# 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.
|
||||
path_without() {
|
||||
local exe="$1"
|
||||
local path=":${PATH}:"
|
||||
for exe; do
|
||||
local found alt util
|
||||
for found in $(which -a "$exe"); do
|
||||
for found in $(PATH="$path" which -a "$exe"); do
|
||||
found="${found%/*}"
|
||||
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
|
||||
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
|
||||
mkdir -p "$alt"
|
||||
for util in bash head cut readlink greadlink; do
|
||||
for util in bash head cut readlink greadlink which; do
|
||||
if [ -x "${found}/$util" ]; then
|
||||
ln -s "${found}/$util" "${alt}/$util"
|
||||
fi
|
||||
|
@ -127,8 +129,10 @@ path_without() {
|
|||
path="${path/:${found}:/:${alt}:}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
path="${path#:}"
|
||||
echo "${path%:}"
|
||||
path="${path%:}"
|
||||
echo "$path"
|
||||
}
|
||||
|
||||
create_hook() {
|
||||
|
|
|
@ -25,7 +25,7 @@ stub_system_python() {
|
|||
}
|
||||
|
||||
@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_output "Warning: no Python detected on the system"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue