Merge pull request #171 from yyuu/simplified-messaging-levels

Simplified messaging levels
This commit is contained in:
Yamashita, Yuu
2016-05-07 22:50:33 +09:00
5 changed files with 67 additions and 16 deletions

View File

@@ -24,7 +24,6 @@ resolve_link() {
unset FORCE unset FORCE
unset QUIET unset QUIET
unset VERBOSE
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
@@ -36,10 +35,6 @@ while [ $# -gt 0 ]; do
"-f" | "--force" ) "-f" | "--force" )
FORCE=1 FORCE=1
;; ;;
"--no-error" )
# for backward compatibility with v20151103 and earlier
QUIET=1
;;
"-q" | "--quiet" ) "-q" | "--quiet" )
QUIET=1 QUIET=1
;; ;;
@@ -47,7 +42,8 @@ while [ $# -gt 0 ]; do
exec pyenv-sh-deactivate exec pyenv-sh-deactivate
;; ;;
"-v" | "--verbose" ) "-v" | "--verbose" )
VERBOSE=1 unset QUIET
PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
;; ;;
* ) * )
break break
@@ -136,7 +132,7 @@ if [[ "${VIRTUAL_ENV}" == "${prefix}" ]]; then
fi fi
fi fi
pyenv-sh-deactivate --force --quiet ${VERBOSE+--verbose} || true pyenv-sh-deactivate --force --quiet || true
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
echo "pyenv-virtualenv: activate ${venv}" 1>&2 echo "pyenv-virtualenv: activate ${venv}" 1>&2
@@ -220,10 +216,14 @@ PYENV_VIRTUALENV_DISABLE_PROMPT="${PYENV_VIRTUALENV_DISABLE_PROMPT:-${VIRTUAL_EN
if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then
case "${shell}" in case "${shell}" in
fish ) fish )
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2 if [ -z "${QUIET}" ]; then
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2
fi
;; ;;
* ) * )
echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2 if [ -z "${QUIET}" ]; then
echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2
fi
cat <<EOS cat <<EOS
export _OLD_VIRTUAL_PS1="\${PS1}"; export _OLD_VIRTUAL_PS1="\${PS1}";
export PS1="(${venv}) \${PS1}"; export PS1="(${venv}) \${PS1}";

View File

@@ -15,22 +15,18 @@ fi
unset FORCE unset FORCE
unset QUIET unset QUIET
unset VERBOSE
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
"-f" | "--force" ) "-f" | "--force" )
FORCE=1 FORCE=1
;; ;;
"--no-error" )
# for backward compatibility with v20151103 and earlier
QUIET=1
;;
"-q" | "--quiet") "-q" | "--quiet")
QUIET=1 QUIET=1
;; ;;
"-v" | "--verbose" ) "-v" | "--verbose" )
VERBOSE=1 unset QUIET
PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
;; ;;
* ) * )
break break

View File

@@ -44,6 +44,31 @@ EOS
unstub pyenv-sh-deactivate unstub pyenv-sh-deactivate
} }
@test "activate virtualenv from current version (quiet)" {
export PYENV_VIRTUALENV_INIT=1
stub pyenv-version-name "echo venv"
stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
stub pyenv-sh-deactivate "--force --quiet : echo deactivated"
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --quiet
assert_success
assert_output <<EOS
deactivated
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
export _OLD_VIRTUAL_PS1="\${PS1}";
export PS1="(venv) \${PS1}";
EOS
unstub pyenv-version-name
unstub pyenv-virtualenv-prefix
unstub pyenv-prefix
unstub pyenv-sh-deactivate
}
@test "activate virtualenv from current version (verbose)" { @test "activate virtualenv from current version (verbose)" {
export PYENV_VIRTUALENV_INIT=1 export PYENV_VIRTUALENV_INIT=1
export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1 export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
@@ -51,7 +76,7 @@ EOS
stub pyenv-version-name "echo venv" stub pyenv-version-name "echo venv"
stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\"" stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\"" stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
stub pyenv-sh-deactivate "--force --quiet --verbose : echo deactivated" stub pyenv-sh-deactivate "--force --quiet : echo deactivated"
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --verbose PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate --verbose

View File

@@ -48,6 +48,36 @@ fi;
EOS EOS
} }
@test "deactivate virtualenv (quiet)" {
export PYENV_VIRTUALENV_INIT=1
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
export PYENV_ACTIVATE_SHELL=
PYENV_SHELL="bash" run pyenv-sh-deactivate --quit
assert_success
assert_output <<EOS
unset PYENV_VIRTUAL_ENV;
unset VIRTUAL_ENV;
if [ -n "\${_OLD_VIRTUAL_PATH}" ]; then
export PATH="\${_OLD_VIRTUAL_PATH}";
unset _OLD_VIRTUAL_PATH;
fi;
if [ -n "\${_OLD_VIRTUAL_PYTHONHOME}" ]; then
export PYTHONHOME="\${_OLD_VIRTUAL_PYTHONHOME}";
unset _OLD_VIRTUAL_PYTHONHOME;
fi;
if [ -n "\${_OLD_VIRTUAL_PS1}" ]; then
export PS1="\${_OLD_VIRTUAL_PS1}";
unset _OLD_VIRTUAL_PS1;
fi;
if declare -f deactivate 1>/dev/null 2>&1; then
unset -f deactivate;
fi;
EOS
}
@test "deactivate virtualenv (verbose)" { @test "deactivate virtualenv (verbose)" {
export PYENV_VIRTUALENV_INIT=1 export PYENV_VIRTUALENV_INIT=1
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv" export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"

0
test/init.bats Executable file → Normal file
View File