Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

187 linhas
4.2 KiB

10 anos atrás
10 anos atrás
10 anos atrás
  1. #!/usr/bin/env bats
  2. load test_helper
  3. export PYENV_ROOT="${TMP}/pyenv"
  4. setup() {
  5. stub pyenv-hooks 'install : true'
  6. stub pyenv-rehash 'true'
  7. }
  8. stub_python_build() {
  9. stub python-build "--lib : $BATS_TEST_DIRNAME/../bin/python-build --lib" "$@"
  10. }
  11. @test "install proper" {
  12. stub_python_build 'echo python-build "$@"'
  13. run pyenv-install 3.4.2
  14. assert_success "python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2"
  15. unstub python-build
  16. unstub pyenv-hooks
  17. unstub pyenv-rehash
  18. }
  19. @test "install pyenv local version by default" {
  20. stub_python_build 'echo python-build "$1"'
  21. stub pyenv-local 'echo 3.4.2'
  22. run pyenv-install
  23. assert_success "python-build 3.4.2"
  24. unstub python-build
  25. unstub pyenv-local
  26. }
  27. @test "list available versions" {
  28. stub_python_build \
  29. "--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'"
  30. run pyenv-install --list
  31. assert_success
  32. assert_output <<OUT
  33. Available versions:
  34. 2.6.9
  35. 2.7.9-rc1
  36. 2.7.9-rc2
  37. 3.4.2
  38. OUT
  39. unstub python-build
  40. }
  41. @test "nonexistent version" {
  42. stub brew false
  43. stub_python_build 'echo ERROR >&2 && exit 2' \
  44. "--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'"
  45. run pyenv-install 2.7.9
  46. assert_failure
  47. assert_output <<OUT
  48. ERROR
  49. The following versions contain \`2.7.9' in the name:
  50. 2.7.9-rc1
  51. 2.7.9-rc2
  52. See all available versions with \`pyenv install --list'.
  53. If the version you need is missing, try upgrading pyenv:
  54. cd ${BATS_TEST_DIRNAME}/../../.. && git pull
  55. OUT
  56. unstub python-build
  57. }
  58. @test "Homebrew upgrade instructions" {
  59. stub brew "--prefix : echo '${BATS_TEST_DIRNAME%/*}'"
  60. stub_python_build 'echo ERROR >&2 && exit 2' \
  61. "--definitions : true"
  62. run pyenv-install 1.9.3
  63. assert_failure
  64. assert_output <<OUT
  65. ERROR
  66. See all available versions with \`pyenv install --list'.
  67. If the version you need is missing, try upgrading pyenv:
  68. brew update && brew upgrade pyenv
  69. OUT
  70. unstub brew
  71. unstub python-build
  72. }
  73. @test "no build definitions from plugins" {
  74. assert [ ! -e "${PYENV_ROOT}/plugins" ]
  75. stub_python_build 'echo $PYTHON_BUILD_DEFINITIONS'
  76. run pyenv-install 3.4.2
  77. assert_success ""
  78. }
  79. @test "some build definitions from plugins" {
  80. mkdir -p "${PYENV_ROOT}/plugins/foo/share/python-build"
  81. mkdir -p "${PYENV_ROOT}/plugins/bar/share/python-build"
  82. stub_python_build "echo \$PYTHON_BUILD_DEFINITIONS | tr ':' $'\\n'"
  83. run pyenv-install 3.4.2
  84. assert_success
  85. assert_output <<OUT
  86. ${PYENV_ROOT}/plugins/bar/share/python-build
  87. ${PYENV_ROOT}/plugins/foo/share/python-build
  88. OUT
  89. }
  90. @test "list build definitions from plugins" {
  91. mkdir -p "${PYENV_ROOT}/plugins/foo/share/python-build"
  92. mkdir -p "${PYENV_ROOT}/plugins/bar/share/python-build"
  93. stub_python_build "--definitions : echo \$PYTHON_BUILD_DEFINITIONS | tr ':' $'\\n'"
  94. run pyenv-install --list
  95. assert_success
  96. assert_output <<OUT
  97. Available versions:
  98. ${PYENV_ROOT}/plugins/bar/share/python-build
  99. ${PYENV_ROOT}/plugins/foo/share/python-build
  100. OUT
  101. }
  102. @test "completion results include build definitions from plugins" {
  103. mkdir -p "${PYENV_ROOT}/plugins/foo/share/python-build"
  104. mkdir -p "${PYENV_ROOT}/plugins/bar/share/python-build"
  105. stub python-build "--definitions : echo \$PYTHON_BUILD_DEFINITIONS | tr ':' $'\\n'"
  106. run pyenv-install --complete
  107. assert_success
  108. assert_output <<OUT
  109. ${PYENV_ROOT}/plugins/bar/share/python-build
  110. ${PYENV_ROOT}/plugins/foo/share/python-build
  111. OUT
  112. }
  113. @test "not enough arguments for pyenv-install" {
  114. stub_python_build
  115. run pyenv-install
  116. assert_failure
  117. assert_output_contains 'Usage: pyenv install'
  118. }
  119. @test "too many arguments for pyenv-install" {
  120. stub_python_build
  121. run pyenv-install 3.4.1 3.4.2
  122. assert_failure
  123. assert_output_contains 'Usage: pyenv install'
  124. }
  125. @test "show help for pyenv-install" {
  126. stub_python_build
  127. run pyenv-install -h
  128. assert_success
  129. assert_output_contains 'Usage: pyenv install'
  130. }
  131. @test "not enough arguments pyenv-uninstall" {
  132. run pyenv-uninstall
  133. assert_failure
  134. assert_output_contains 'Usage: pyenv uninstall'
  135. }
  136. @test "too many arguments for pyenv-uninstall" {
  137. run pyenv-uninstall 3.4.1 3.4.2
  138. assert_failure
  139. assert_output_contains 'Usage: pyenv uninstall'
  140. }
  141. @test "show help for pyenv-uninstall" {
  142. run pyenv-uninstall -h
  143. assert_success
  144. assert_output_contains 'Usage: pyenv uninstall'
  145. }