rmdir.test 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. [ -f testing.sh ] && . testing.sh
  3. #testing "name" "command" "result" "infile" "stdin"
  4. mkdir one
  5. testing "rmdir" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" ""
  6. touch walrus
  7. testing "file" \
  8. "rmdir walrus 2> /dev/null || [ -f walrus ] && echo yes" "yes\n" "" ""
  9. mkdir one two
  10. testing "one two" \
  11. "rmdir one two 2> /dev/null && [ ! -d one ] && [ ! -d two ] && echo yes" \
  12. "yes\n" "" ""
  13. mkdir one two three
  14. testing "one missing two file three" \
  15. "rmdir one missing two walrus three 2> /dev/null || [ ! -d three ] && echo yes" \
  16. "yes\n" "" ""
  17. rm walrus
  18. mkdir one
  19. chmod 000 one
  20. testing "mode 000" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" ""
  21. mkdir temp
  22. touch temp/thing
  23. testing "non-empty" \
  24. "rmdir temp 2>/dev/null || [ -d temp ] && echo yes" "yes\n" "" ""
  25. testing "-p dir/file" \
  26. "rmdir -p temp/thing 2>/dev/null || [ -f temp/thing ] && echo yes" \
  27. "yes\n" "" ""
  28. mkdir -p temp/one/two/three
  29. testing "-p part of path" \
  30. "rmdir -p temp/one/two/three 2>/dev/null || [ -d temp ] && [ ! -e temp/one ] && echo yes" \
  31. "yes\n" "" ""
  32. rm -rf temp
  33. skipnot [ $UID -eq 0 ]
  34. testing '-p abspath' \
  35. 'mkdir -p /test/2/3 && rmdir -p /test/2/3 && [ ! -e /test ] && echo yes' \
  36. 'yes\n' '' ''
  37. mkdir -p one/two/three
  38. testing "-p one/two/three" \
  39. "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" ""
  40. mkdir -p one/two/three
  41. testing "-p one/two/three/" \
  42. "rmdir -p one/two/three/ && [ ! -e one ] && echo yes" "yes\n" "" ""
  43. #mkdir -p one/two/three
  44. #chmod 000 one/two/three one/two one
  45. #testing "-p one/two/three" \
  46. # "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" ""