您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

115 行
2.3 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. @test "without args shows summary of common commands" {
  4. run pyenv-help
  5. assert_success
  6. assert_line "Usage: pyenv <command> [<args>]"
  7. assert_line "Some useful pyenv commands are:"
  8. }
  9. @test "invalid command" {
  10. run pyenv-help hello
  11. assert_failure "pyenv: no such command \`hello'"
  12. }
  13. @test "shows help for a specific command" {
  14. mkdir -p "${PYENV_TEST_DIR}/bin"
  15. cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
  16. #!shebang
  17. # Usage: pyenv hello <world>
  18. # Summary: Says "hello" to you, from pyenv
  19. # This command is useful for saying hello.
  20. echo hello
  21. SH
  22. run pyenv-help hello
  23. assert_success
  24. assert_output <<SH
  25. Usage: pyenv hello <world>
  26. This command is useful for saying hello.
  27. SH
  28. }
  29. @test "replaces missing extended help with summary text" {
  30. mkdir -p "${PYENV_TEST_DIR}/bin"
  31. cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
  32. #!shebang
  33. # Usage: pyenv hello <world>
  34. # Summary: Says "hello" to you, from pyenv
  35. echo hello
  36. SH
  37. run pyenv-help hello
  38. assert_success
  39. assert_output <<SH
  40. Usage: pyenv hello <world>
  41. Says "hello" to you, from pyenv
  42. SH
  43. }
  44. @test "extracts only usage" {
  45. mkdir -p "${PYENV_TEST_DIR}/bin"
  46. cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
  47. #!shebang
  48. # Usage: pyenv hello <world>
  49. # Summary: Says "hello" to you, from pyenv
  50. # This extended help won't be shown.
  51. echo hello
  52. SH
  53. run pyenv-help --usage hello
  54. assert_success "Usage: pyenv hello <world>"
  55. }
  56. @test "multiline usage section" {
  57. mkdir -p "${PYENV_TEST_DIR}/bin"
  58. cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
  59. #!shebang
  60. # Usage: pyenv hello <world>
  61. # pyenv hi [everybody]
  62. # pyenv hola --translate
  63. # Summary: Says "hello" to you, from pyenv
  64. # Help text.
  65. echo hello
  66. SH
  67. run pyenv-help hello
  68. assert_success
  69. assert_output <<SH
  70. Usage: pyenv hello <world>
  71. pyenv hi [everybody]
  72. pyenv hola --translate
  73. Help text.
  74. SH
  75. }
  76. @test "multiline extended help section" {
  77. mkdir -p "${PYENV_TEST_DIR}/bin"
  78. cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
  79. #!shebang
  80. # Usage: pyenv hello <world>
  81. # Summary: Says "hello" to you, from pyenv
  82. # This is extended help text.
  83. # It can contain multiple lines.
  84. #
  85. # And paragraphs.
  86. echo hello
  87. SH
  88. run pyenv-help hello
  89. assert_success
  90. assert_output <<SH
  91. Usage: pyenv hello <world>
  92. This is extended help text.
  93. It can contain multiple lines.
  94. And paragraphs.
  95. SH
  96. }