logo

utils

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

pwd (1378B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
  4. atf_test_case simple
  5. simple_body() {
  6. atf_check -o "inline:${PWD}\n" ../bin/pwd
  7. atf_check -o "inline:$(atf_get_srcdir)\n" ../bin/pwd
  8. }
  9. atf_test_case args
  10. args_body() {
  11. atf_check -s exit:1 -e "inline:usage: pwd\n" ../bin/pwd -H
  12. }
  13. atf_test_case enoent cleanup
  14. enoent_body() {
  15. mkdir -p "$(atf_get_srcdir)/remove-me" || exit 1
  16. cd "$(atf_get_srcdir)/remove-me" || exit 1
  17. atf_check -o "inline:$(atf_get_srcdir)/remove-me\n" "$(atf_get_srcdir)/../bin/pwd"
  18. rm -fr "$(atf_get_srcdir)/remove-me" || exit 1
  19. atf_check -s exit:1 -e 'inline:getcwd: No such file or directory\n' "$(atf_get_srcdir)/../bin/pwd"
  20. }
  21. enoent_cleanup() {
  22. rm -fr "$(atf_get_srcdir)/remove-me"
  23. }
  24. atf_test_case devfull
  25. devfull_body() {
  26. has_glibc && atf_expect_fail "glibc ignoring write errors for puts()"
  27. [ "$(uname -s)" = "NetBSD" ] && atf_expect_fail "NetBSD ignoring write errors for puts()"
  28. [ "$(uname -s)" = "FreeBSD" ] && atf_expect_fail "FreeBSD ignoring write errors for puts()"
  29. atf_check -s exit:1 sh -c '../bin/pwd >/dev/full'
  30. }
  31. atf_init_test_cases() {
  32. cd "$(atf_get_srcdir)" || exit 1
  33. . ../test_functions.sh
  34. atf_add_test_case simple
  35. atf_add_test_case args
  36. atf_add_test_case enoent
  37. atf_add_test_case devfull
  38. }