logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

dirname (897B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. atf_test_case noargs
  5. noargs_body() {
  6. atf_check -e "inline:usage: dirname string\n" -s exit:1 ../cmd/dirname
  7. }
  8. atf_test_case one_slash
  9. one_slash_body() {
  10. atf_check -o "inline:/usr\n" ../cmd/dirname "/usr/bin"
  11. }
  12. atf_test_case two_slash
  13. two_slash_body() {
  14. atf_check -o "inline:/usr\n" ../cmd/dirname "/usr//bin"
  15. }
  16. atf_test_case two_dash
  17. two_dash_body() {
  18. atf_check -o "inline:/usr\n" ../cmd/dirname -- "/usr//bin"
  19. }
  20. atf_test_case badarg
  21. badarg_body() {
  22. atf_check -s exit:1 -e "inline:usage: dirname string\n" ../cmd/dirname -a "/usr//bin"
  23. }
  24. atf_init_test_cases() {
  25. cd "$(atf_get_srcdir)" || exit 1
  26. atf_add_test_case noargs
  27. atf_add_test_case badarg
  28. atf_add_test_case one_slash
  29. atf_add_test_case two_slash
  30. atf_add_test_case two_dash
  31. }