From 1c6758009e82c47b5b341d418be2be401ef31482 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 6 Sep 2019 22:20:46 +0300 Subject: Add builtins support --- tests/builtin/rm.testscript | 105 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/builtin/rm.testscript (limited to 'tests/builtin/rm.testscript') 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 + } +} -- cgit v1.1