aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/mv.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/mv.testscript
parent070871d97b4f6440c3f0fc647ece73b53a5837db (diff)
Add builtins support
Diffstat (limited to 'tests/builtin/mv.testscript')
-rw-r--r--tests/builtin/mv.testscript182
1 files changed, 182 insertions, 0 deletions
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
+}