aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/ln.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/ln.testscript
parent070871d97b4f6440c3f0fc647ece73b53a5837db (diff)
Add builtins support
Diffstat (limited to 'tests/builtin/ln.testscript')
-rw-r--r--tests/builtin/ln.testscript217
1 files changed, 217 insertions, 0 deletions
diff --git a/tests/builtin/ln.testscript b/tests/builtin/ln.testscript
new file mode 100644
index 0000000..ed4ca67
--- /dev/null
+++ b/tests/builtin/ln.testscript
@@ -0,0 +1,217 @@
+# file : tests/builtin/ln.testscript
+# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+test.arguments = "ln"
+test.options += -c
+
+: unknown-option
+:
+$* -u >'option -u' 2>"ln: unknown option '-u'" == 1
+
+: args
+:
+{
+ : -s-option
+ :
+ $* 2>"ln: missing -s|--symbolic option" == 1
+
+ : none
+ :
+ $* -s 2>"ln: missing arguments" == 1
+
+ : no-target
+ :
+ $* -s a 2>"ln: missing target path" == 1
+
+ : no-trailing-sep
+ :
+ $* -s a b c 2>"ln: multiple target paths with non-directory link path" == 1
+
+ : empty
+ :
+ {
+ : link
+ :
+ $* -s '' 2>"ln: invalid path ''" == 1
+
+ : target1
+ :
+ $* -s '' a 2>"ln: invalid path ''" == 1
+
+ : target2
+ :
+ $* -s '' a b/ 2>"ln: invalid path ''" == 1
+ }
+}
+
+: file
+:
+: Test creating a file symlink.
+:
+{
+ : non-existing-link-path
+ :
+ {
+ touch a;
+
+ $* -s a b >>/~%EOO% &b;
+ %create .+/b true%
+ %create .+/b false%
+ EOO
+
+ test -f b
+ }
+
+ : existing-link
+ :
+ {
+ : file
+ :
+ {
+ touch a b;
+
+ $* -s a b >>/~%EOO% 2>>/~%EOE% != 0
+ %create .+/b true%
+ EOO
+ %(
+ %ln: unable to create .+link '.+/b' to '.+/a': .+%|
+ %ln: unable to copy file '.+/a' to '.+/b': .+%
+ %)
+ EOE
+ }
+
+ : dir
+ :
+ {
+ touch a;
+ mkdir b;
+
+ $* -s a b >>/~%EOO% 2>>/~%EOE% != 0
+ %create .+/b true%
+ EOO
+ %(
+ %ln: unable to create .+link '.+/b' to '.+/a': .+%|
+ %ln: unable to copy file '.+/a' to '.+/b': .+%
+ %)
+ EOE
+ }
+ }
+
+ : non-existing
+ {
+ : target
+ :
+ {
+ $* -s a b 2>>/~%EOE% != 0
+ %ln: unable to create symlink to '.+/a': no such file or directory%
+ EOE
+ }
+
+ : link-dir
+ :
+ {
+ touch a;
+
+ $* -s a b/c >>/~%EOO% 2>>/~%EOE% != 0
+ %create .+/b/c true%
+ EOO
+ %(
+ %ln: unable to create .+link '.+/b/c' to '.+/a': .+%|
+ %ln: unable to copy file '.+/a' to '.+/b/c': .+%
+ %)
+ EOE
+ }
+ }
+}
+
+: dir
+:
+: Test creating a directory symlink.
+:
+{
+ : non-existing-link-path
+ :
+ {
+ mkdir a;
+ touch a/b;
+
+ $* -s a c >>/~%EOO% &c;
+ %create .+/c true%
+ %create .+/c false%
+ EOO
+
+ test -f c/b
+ }
+
+ : existing-link
+ :
+ {
+ : dir
+ :
+ {
+ mkdir a b;
+
+ $* -s a b >>/~%EOO% 2>>/~%EOE% != 0
+ %create .+/b true%
+ EOO
+ %(
+ %ln: unable to create .+link '.+/b' to '.+/a': .+%|
+ %ln: unable to copy directory '.+/a' to '.+/b': .+%
+ %)
+ EOE
+ }
+
+ : file
+ :
+ {
+ mkdir a;
+ touch b;
+
+ $* -s a b >>/~%EOO% 2>>/~%EOE% != 0
+ %create .+/b true%
+ EOO
+ %(
+ %ln: unable to create .+link '.+/b' to '.+/a': .+%|
+ %ln: unable to copy directory '.+/a' to '.+/b': .+%
+ %)
+ EOE
+ }
+ }
+
+ : non-existing
+ {
+ : link-dir
+ :
+ {
+ mkdir a;
+
+ $* -s a b/c >>/~%EOO% 2>>/~%EOE% != 0
+ %create .+/b/c true%
+ EOO
+ %(
+ %ln: unable to create .+link '.+/b/c' to '.+/a': .+%|
+ %ln: unable to copy directory '.+/a' to '.+/b/c': .+%
+ %)
+ EOE
+ }
+ }
+}
+
+: multiple-targets
+:
+: Test creating links for multiple targets in the specified directory.
+:
+{
+ touch a;
+ mkdir b c;
+
+ $* -s a b c/ >>/~%EOO% &c/a &c/b;
+ %create .+/c/a true%
+ %create .+/c/a false%
+ %create .+/c/b true%
+ %create .+/c/b false%
+ EOO
+
+ test -f c/a && test -d c/b
+}