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/mv.testscript | 182 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 tests/builtin/mv.testscript (limited to 'tests/builtin/mv.testscript') diff --git a/tests/builtin/mv.testscript b/tests/builtin/mv.testscript new file mode 100644 index 0000000..2647d0f --- /dev/null +++ b/tests/builtin/mv.testscript @@ -0,0 +1,182 @@ +# file : tests/builtin/mv.testscript +# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = "mv" +test.options += -c + +: unknown-option +: +$* -u >'option -u' 2>"mv: unknown option '-u'" == 1 + +: args +: +{ + : none + : + $* 2>"mv: missing arguments" == 1 + + : no-source + : + $* a 2>"mv: missing source path" == 1 + + : no-trailing-sep + : + $* a b c 2>"mv: multiple source paths without trailing separator for destination directory" == 1 + + : empty + : + { + : dest + : + $* '' 2>"mv: invalid path ''" == 1 + + : src1 + : + $* '' a 2>"mv: invalid path ''" == 1 + + : src2 + : + $* '' a b/ 2>"mv: invalid path ''" == 1 + } +} + +: synopsis-1 +: +: Move an entity to the specified path. +: +{ + : file + : + { + : existing + : + { + : to-non-existing + : + { + touch a &!a; + + $* a b >>/~%EOO% &b; + %move .+/a .+/b false true% + %move .+/a .+/b false false% + EOO + + test -f b && test -f a == 1 + } + + : to-existing + : + { + touch a b &!a; + + $* a b >>/~%EOO%; + %move .+/a .+/b false true% + %move .+/a .+/b false false% + EOO + + test -f b && test -f a == 1 + } + + : to-self + : + { + touch a; + + $* a a >/~'%move .+/a .+/a false true%' 2>>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to itself% + EOE + } + + : to-dir + : + { + touch a; + mkdir b; + + $* a b >/~'%move .+/a .+/b false true%' 2>>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + } + } + } + + : dir + : + { + : existing + : + { + : to-non-existing + : + { + mkdir a &!a/; + + $* a b &b/ >>/~%EOO%; + %move .+/a .+/b false true% + %move .+/a .+/b false false% + EOO + + test -d b && test -d a == 1 + } + + : to-non-empty + : + { + mkdir a b; + touch b/c; + + $* a b >/~'%move .+/a .+/b false true%' 2>>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + } + + : to-non-dir + : + { + mkdir a; + touch b; + + $* a b >/~'%move .+/a .+/b false true%' 2>>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + } + } + + : overlap + : + { + mkdir a; + + $* a a/b >/~'%move .+/a .+/a/b false true%' 2>>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/a/b': .+% + EOE + } + } + + : non-existing + : + { + $* a b >/~'%move .+/a .+/b false true%' 2>>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + } +} + +: synopsis-2 +: +: Move entities into the specified directory. +: +{ + mkdir a c &!a/; + touch a/b b &!a/b &!b; + + $* a b c/ >>/~%EOO% &c/a/ &c/a/b &c/b; + %move .+/a .+/c/a false true% + %move .+/a .+/c/a false false% + %move .+/b .+/c/b false true% + %move .+/b .+/c/b false false% + EOO + + test -d c/a && test -f c/a/b && test -f c/b +} -- cgit v1.1