Fix broken tests

This commit is contained in:
Yamashita Yuu 2014-01-03 02:05:40 +09:00
parent 88922e2bc0
commit 3dd9332eee
9 changed files with 62 additions and 47 deletions

View file

@ -38,13 +38,14 @@ versions=($@)
if [ "$versions" = "--unset" ]; then
rm -f .python-version .pyenv-version
elif [ -n "$versions" ]; then
if [ "$(PYENV_VERSION= pyenv-version-origin)" -ef .pyenv-version ]; then
previous_file="$(PYENV_VERSION= pyenv-version-origin || true)"
pyenv-version-file-write .python-version "${versions[@]}"
if [ "$previous_file" -ef .pyenv-version ]; then
rm -f .pyenv-version
{ echo "pyenv: removed existing \`.pyenv-version' file and migrated"
echo " local version specification to \`.python-version' file"
} >&2
fi
pyenv-version-file-write .python-version "${versions[@]}"
else
OLDIFS="$IFS"
IFS=: versions=($(

View file

@ -16,22 +16,26 @@ if [ "$1" = "--complete" ]; then
fi
if [ -n "$1" ]; then
versions=($@)
OLDIFS="$IFS"
IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
export PYENV_VERSION
else
OLDIFS="$IFS"
IFS=: versions=($(pyenv-version-name))
{ IFS=:
export PYENV_VERSION="$*"
}
IFS="$OLDIFS"
elif [ -z "$PYENV_VERSION" ]; then
PYENV_VERSION="$(pyenv-version-name)"
fi
PYENV_PREFIX_PATHS=()
for version in "${versions[@]}"; do
OLDIFS="$IFS"
{ IFS=:
for version in ${PYENV_VERSION}; do
if [ "$version" = "system" ]; then
PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python || true)"
if PYTHON_PATH="$(pyenv-which python 2>/dev/null)"; then
PYENV_PREFIX_PATH="${PYTHON_PATH%/bin/*}"
else
echo "pyenv: system version not found in PATH" >&2
exit 1
fi
else
PYENV_PREFIX_PATH="${PYENV_ROOT}/versions/${version}"
fi
@ -42,6 +46,8 @@ for version in "${versions[@]}"; do
exit 1
fi
done
}
IFS="$OLDIFS"
OLDIFS="$IFS"
{ IFS=:

View file

@ -5,7 +5,7 @@ set -e
[ -n "$PYENV_DEBUG" ] && set -x
PYENV_VERSION_FILE="$1"
shift
shift || true
versions=("$@")
if [ -z "$versions" ] || [ -z "$PYENV_VERSION_FILE" ]; then

View file

@ -5,18 +5,10 @@ set -e
if [ -z "$PYENV_VERSION" ]; then
PYENV_VERSION_FILE="$(pyenv-version-file)"
OLDIFS="$IFS"
IFS=: versions=($(pyenv-version-file-read "$PYENV_VERSION_FILE" || true))
IFS=: PYENV_VERSION="${versions[*]}"
IFS="$OLDIFS"
export PYENV_VERSION
else
OLDIFS="$IFS"
IFS=: versions=($(echo "${PYENV_VERSION}"))
IFS="$OLDIFS"
PYENV_VERSION="$(pyenv-version-file-read "$PYENV_VERSION_FILE" || true)"
fi
if [ -z "$versions" ] || [ "$versions" = "system" ]; then
if [ -z "$PYENV_VERSION" ] || [ "$PYENV_VERSION" = "system" ]; then
echo "system"
exit
fi
@ -26,11 +18,27 @@ version_exists() {
[ -d "${PYENV_ROOT}/versions/${version}" ]
}
for version in "${versions[@]}"; do
if [ "$version" != "system" ] && ! version_exists "$version"; then
versions=()
OLDIFS="$IFS"
{ IFS=:
for version in ${PYENV_VERSION}; do
if version_exists "$version" || [ "$version" = "system" ]; then
versions=("${versions[@]}" "${version}")
elif version_exists "${version#python-}"; then
{ echo "warning: ignoring extraneous \`python-' prefix in version \`${version}'"
echo " (set by $(pyenv-version-origin))"
} >&2
versions=("${versions[@]}" "${version#python-}")
else
echo "pyenv: version \`$version' is not installed" >&2
exit 1
fi
done
}
IFS="$OLDIFS"
echo "${PYENV_VERSION}"
OLDIFS="$IFS"
{ IFS=:
echo "${versions[*]}"
}
IFS="$OLDIFS"

View file

@ -29,8 +29,8 @@ create_executable() {
run pyenv-completions exec
assert_success
assert_output <<OUT
rake
python
rake
OUT
}

View file

@ -5,7 +5,7 @@ load test_helper
@test "blank invocation" {
run pyenv
assert_success
assert [ "${lines[0]}" = "pyenv 0.4.0" ]
assert [ "${lines[0]}" == "pyenv 0.4.0-20131217" ]
}
@test "invalid command" {

View file

@ -47,9 +47,9 @@ create_executable() {
run ls "${PYENV_ROOT}/shims"
assert_success
assert_output <<OUT
python
rake
rspec
python
OUT
}
@ -80,8 +80,8 @@ OUT
run ls "${PYENV_ROOT}/shims"
assert_success
assert_output <<OUT
rspec
python
rspec
OUT
}

View file

@ -38,7 +38,7 @@ setup() {
@test "reads only the first word from file" {
cat > my-version <<<"1.9.3-p194@tag 1.8.7 hi"
run pyenv-version-file-read my-version
assert_success "1.9.3-p194@tag"
assert_success "1.9.3-p194@tag:1.8.7:hi"
}
@test "loads only the first line in file" {
@ -47,7 +47,7 @@ setup() {
1.9.3 two
IN
run pyenv-version-file-read my-version
assert_success "1.8.7"
assert_success "1.8.7:one:1.9.3:two"
}
@test "ignores leading blank lines" {