mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-16 15:23:53 -05:00
Merge remote-tracking branch 'rbenv/master' into rbenv-1.0
This commit is contained in:
@@ -2,22 +2,13 @@
|
||||
|
||||
load test_helper
|
||||
|
||||
export GIT_DIR="${PYENV_TEST_DIR}/.git"
|
||||
|
||||
setup() {
|
||||
mkdir -p "$HOME"
|
||||
git config --global user.name "Tester"
|
||||
git config --global user.email "tester@test.local"
|
||||
|
||||
mkdir -p "${PYENV_TEST_DIR}/bin"
|
||||
cat > "${PYENV_TEST_DIR}/bin/git" <<CMD
|
||||
#!$BASH
|
||||
if [[ \$1 == remote && \$PWD != "\$PYENV_TEST_DIR"/* ]]; then
|
||||
echo "not allowed" >&2
|
||||
exit 1
|
||||
else
|
||||
exec $(which git) "\$@"
|
||||
fi
|
||||
CMD
|
||||
chmod +x "${PYENV_TEST_DIR}/bin/git"
|
||||
cd "$PYENV_TEST_DIR"
|
||||
}
|
||||
|
||||
git_commit() {
|
||||
@@ -28,47 +19,37 @@ git_commit() {
|
||||
assert [ ! -e "$PYENV_ROOT" ]
|
||||
run pyenv---version
|
||||
assert_success
|
||||
[[ $output == "pyenv 20"* ]]
|
||||
[[ $output == "ybenv "?.?.? ]]
|
||||
}
|
||||
|
||||
@test "doesn't read version from non-pyenv repo" {
|
||||
mkdir -p "$PYENV_ROOT"
|
||||
cd "$PYENV_ROOT"
|
||||
git init
|
||||
git remote add origin https://github.com/homebrew/homebrew.git
|
||||
git_commit
|
||||
git tag v1.0
|
||||
|
||||
cd "$PYENV_TEST_DIR"
|
||||
run pyenv---version
|
||||
assert_success
|
||||
[[ $output == "pyenv 20"* ]]
|
||||
[[ $output == "pyenv "?.?.? ]]
|
||||
}
|
||||
|
||||
@test "reads version from git repo" {
|
||||
mkdir -p "$PYENV_ROOT"
|
||||
cd "$PYENV_ROOT"
|
||||
git init
|
||||
git remote add origin https://github.com/yyuu/pyenv.git
|
||||
git_commit
|
||||
git tag v20380119
|
||||
git tag v0.4.1
|
||||
git_commit
|
||||
git_commit
|
||||
|
||||
cd "$PYENV_TEST_DIR"
|
||||
run pyenv---version
|
||||
assert_success
|
||||
[[ $output == "pyenv 20380119-2-g"* ]]
|
||||
assert_success "pyenv 0.4.1-2-g$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
@test "prints default version if no tags in git repo" {
|
||||
mkdir -p "$PYENV_ROOT"
|
||||
cd "$PYENV_ROOT"
|
||||
git init
|
||||
git remote add origin https://github.com/yyuu/pyenv.git
|
||||
git_commit
|
||||
|
||||
cd "$PYENV_TEST_DIR"
|
||||
run pyenv---version
|
||||
[[ $output == "pyenv 20"* ]]
|
||||
[[ $output == "pyenv "?.?.? ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user