1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-08 03:23:48 -05:00

upgrade bats to v1.10.0

fix bats warnings
This commit is contained in:
rockandska
2025-09-15 13:38:35 +02:00
parent 68edd564cf
commit 8990110dcf
5 changed files with 32 additions and 13 deletions

3
.gitignore vendored
View File

@@ -6,7 +6,8 @@
/libexec/*.dylib
/src/Makefile
/src/*.o
/bats/
/bats
/bats-*/
/default-packages
.idea
*.un~

View File

@@ -1,3 +1,5 @@
BATS_VERSION = v1.10.0
.PHONY: test test-build test-unit test-plugin
# Do not pass in user flags to build tests.
@@ -25,5 +27,11 @@ test-build:
[ -e $(PYTHON_BUILD_TEST_PREFIX)/bin/pip ]
$(PYTHON_BUILD_TEST_PREFIX)/bin/pip -V
bats:
git clone --depth 1 --branch v1.2.0 https://github.com/bats-core/bats-core.git bats
.SECONDARY: bats-$(BATS_VERSION)
bats-$(BATS_VERSION):
rm -rf bats
ln -sf bats-$(BATS_VERSION) bats
git clone --depth 1 --branch $(BATS_VERSION) https://github.com/bats-core/bats-core.git bats-$(BATS_VERSION)
.PHONY: bats
bats: bats-$(BATS_VERSION)

View File

@@ -293,10 +293,11 @@ OUT
}
@test "invalid arguments for pyenv-uninstall" {
bats_require_minimum_version 1.5.0
mkdir -p "${PYENV_ROOT}/versions/3.10.3"
mkdir -p "${PYENV_ROOT}/versions/3.10.4"
run pyenv-uninstall -f 3.10.3 --invalid-option 3.10.4
run -127 pyenv-uninstall -f 3.10.3 --invalid-option 3.10.4
assert_failure
assert [ -d "${PYENV_ROOT}/versions/3.10.3" ]

View File

@@ -15,8 +15,9 @@ create_executable() {
}
@test "fails with invalid version" {
bats_require_minimum_version 1.5.0
export PYENV_VERSION="3.4"
run pyenv-exec nonexistent
run -127 pyenv-exec nonexistent
assert_failure <<EOF
pyenv: version \`3.4' is not installed (set by PYENV_VERSION environment variable)
pyenv: nonexistent: command not found
@@ -24,10 +25,11 @@ EOF
}
@test "fails with invalid version set from file" {
bats_require_minimum_version 1.5.0
mkdir -p "$PYENV_TEST_DIR"
cd "$PYENV_TEST_DIR"
echo 2.7 > .python-version
run pyenv-exec nonexistent
run -127 pyenv-exec nonexistent
assert_failure <<EOF
pyenv: version \`2.7' is not installed (set by $PWD/.python-version)
pyenv: nonexistent: command not found

View File

@@ -60,17 +60,19 @@ create_executable() {
}
@test "doesn't include current directory in PATH search" {
bats_require_minimum_version 1.5.0
mkdir -p "$PYENV_TEST_DIR"
cd "$PYENV_TEST_DIR"
touch kill-all-humans
chmod +x kill-all-humans
PATH="$(path_without "kill-all-humans")" PYENV_VERSION=system run pyenv-which kill-all-humans
PATH="$(path_without "kill-all-humans")" PYENV_VERSION=system run -127 pyenv-which kill-all-humans
assert_failure "pyenv: kill-all-humans: command not found"
}
@test "version not installed" {
bats_require_minimum_version 1.5.0
create_executable "3.4" "py.test"
PYENV_VERSION=3.3 run pyenv-which py.test
PYENV_VERSION=3.3 run -127 pyenv-which py.test
assert_failure <<OUT
pyenv: version \`3.3' is not installed (set by PYENV_VERSION environment variable)
pyenv: py.test: command not found
@@ -84,8 +86,9 @@ OUT
}
@test "versions not installed" {
bats_require_minimum_version 1.5.0
create_executable "3.4" "py.test"
PYENV_VERSION=2.7:3.3 run pyenv-which py.test
PYENV_VERSION=2.7:3.3 run -127 pyenv-which py.test
assert_failure <<OUT
pyenv: version \`2.7' is not installed (set by PYENV_VERSION environment variable)
pyenv: version \`3.3' is not installed (set by PYENV_VERSION environment variable)
@@ -100,22 +103,25 @@ OUT
}
@test "no executable found" {
bats_require_minimum_version 1.5.0
create_executable "2.7" "py.test"
PYENV_VERSION=2.7 run pyenv-which fab
PYENV_VERSION=2.7 run -127 pyenv-which fab
assert_failure "pyenv: fab: command not found"
}
@test "no executable found for system version" {
PATH="$(path_without "rake")" PYENV_VERSION=system run pyenv-which rake
bats_require_minimum_version 1.5.0
PATH="$(path_without "rake")" PYENV_VERSION=system run -127 pyenv-which rake
assert_failure "pyenv: rake: command not found"
}
@test "executable found in other versions" {
bats_require_minimum_version 1.5.0
create_executable "2.7" "python"
create_executable "3.3" "py.test"
create_executable "3.4" "py.test"
PYENV_VERSION=2.7 run pyenv-which py.test
PYENV_VERSION=2.7 run -127 pyenv-which py.test
assert_failure
assert_output <<OUT
pyenv: py.test: command not found
@@ -188,11 +194,12 @@ exit
}
@test "skip advice supresses error messages" {
bats_require_minimum_version 1.5.0
create_executable "2.7" "python"
create_executable "3.3" "py.test"
create_executable "3.4" "py.test"
PYENV_VERSION=2.7 run pyenv-which py.test --skip-advice
PYENV_VERSION=2.7 run -127 pyenv-which py.test --skip-advice
assert_failure
assert_output <<OUT
pyenv: py.test: command not found