diff options
Diffstat (limited to 'tests/builtin/rm.testscript')
-rw-r--r-- | tests/builtin/rm.testscript | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/builtin/rm.testscript b/tests/builtin/rm.testscript new file mode 100644 index 0000000..991b0f6 --- /dev/null +++ b/tests/builtin/rm.testscript @@ -0,0 +1,105 @@ +# file : tests/builtin/rm.testscript +# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = "rm" +test.options += -c + +: unknown-option +: +$* -u >'option -u' 2>"rm: unknown option '-u'" == 1 + +: no-args +: +{ + : fail + : + : Removing with no arguments fails. + : + $* 2>"rm: missing file" == 1 + + : force + : + : Removing with no arguments succeeds with -f option. + : + $* -f +} + +: file +: +{ + : exists + : + : Removing existing file succeeds. + : + { + touch a &!a; + + $* a >>/~%EOO% + %remove .+/a false true% + %remove .+/a false false% + EOO + } + + : not-exists + : + { + : fail + : + : Removing non-existing file fails. + : + $* a >/~'%remove .+/a false true%' 2>>/~%EOE% == 1 + %rm: unable to remove '.+/a': .+% + EOE + + : force + : + : Removing non-existing file succeeds with -f option. + : + $* -f a >>/~%EOO% + %remove .+/a true true% + %remove .+/a true false% + EOO + } +} + +: dir +: +{ + : default + : + : Removing directory fails by default. + : + { + mkdir a; + + $* a >/~'%remove .+/a false true%' 2>>/~%EOE% == 1 + %rm: '.+/a' is a directory% + EOE + } + + : recursive + : + : Removing directory succeeds with -r option. + : + { + mkdir -p a/b &!a &!a/b; + + $* -r a >>/~%EOO% + %remove .+/a false true% + %remove .+/a false false% + EOO + } +} + +: path +: +{ + : empty + : + : Removing an empty path fails. + : + { + $* '' 2>"rm: invalid path ''" == 1 + } +} |