aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/rmdir.testscript
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-06 22:20:46 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-27 17:08:05 +0300
commit1c6758009e82c47b5b341d418be2be401ef31482 (patch)
treed3ef8c053280477086f6230e3d25ff90b25871a2 /tests/builtin/rmdir.testscript
parent070871d97b4f6440c3f0fc647ece73b53a5837db (diff)
Add builtins support
Diffstat (limited to 'tests/builtin/rmdir.testscript')
-rw-r--r--tests/builtin/rmdir.testscript95
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/builtin/rmdir.testscript b/tests/builtin/rmdir.testscript
new file mode 100644
index 0000000..a63f701
--- /dev/null
+++ b/tests/builtin/rmdir.testscript
@@ -0,0 +1,95 @@
+# file : tests/builtin/rmdir.testscript
+# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+test.arguments = "rmdir"
+test.options += -c
+
+: unknown-option
+:
+rmdir -u 2>"rmdir: unknown option '-u'" == 1
+
+: no-args
+:
+{
+ : fail
+ :
+ : Removing with no arguments fails.
+ :
+ $* 2>"rmdir: missing directory" == 1
+
+ : force
+ :
+ : Removing with no arguments succeeds with -f option.
+ :
+ $* -f
+}
+
+: dir
+:
+{
+ : empty-path
+ :
+ : Removing an empty path fails.
+ :
+ $* '' 2>"rmdir: invalid path ''" == 1
+
+ : exists
+ :
+ : Removing existing directory succeeds.
+ :
+ {
+ mkdir a &!a;
+
+ $* a >>/~%EOO%
+ %remove .+/a/ false true%
+ %remove .+/a/ false false%
+ EOO
+ }
+
+ : not-exists
+ :
+ {
+ : fail
+ : Removing non-existing directory fails.
+ :
+ {
+ $* a >/~'%remove .+/a/ false true%' 2>>/~%EOE% == 1
+ %rmdir: unable to remove '.+/a': .+%
+ EOE
+ }
+
+ : force
+ :
+ : Removing non-existing directory succeeds with -f option.
+ :
+ $* -f a >>/~%EOO%
+ %remove .+/a/ true true%
+ %remove .+/a/ true false%
+ EOO
+ }
+
+ : not-empty
+ :
+ : Removing non-empty directory fails.
+ :
+ {
+ mkdir -p a/b;
+
+ $* a >/~'%remove .+/a/ false true%' 2>>/~%EOE% == 1
+ %rmdir: unable to remove '.+/a': .+%
+ EOE
+ }
+
+ : not-dir
+ :
+ : Removing not a directory path fails.
+ :
+ {
+ touch a;
+
+ $* a >/~'%remove .+/a/ false true%' 2>>/~%EOE% == 1
+ %rmdir: unable to remove '.+/a': .+%
+ EOE
+ }
+}