aboutsummaryrefslogtreecommitdiff
path: root/tests/builtin/touch.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/touch.testscript
parent070871d97b4f6440c3f0fc647ece73b53a5837db (diff)
Add builtins support
Diffstat (limited to 'tests/builtin/touch.testscript')
-rw-r--r--tests/builtin/touch.testscript92
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/builtin/touch.testscript b/tests/builtin/touch.testscript
new file mode 100644
index 0000000..aa0ea10
--- /dev/null
+++ b/tests/builtin/touch.testscript
@@ -0,0 +1,92 @@
+# file : tests/builtin/touch.testscript
+# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+test.arguments = "touch"
+
+: file
+:
+$* a &a
+
+: file-create
+:
+: Test that file is created. If it didn't then 'rm' would fail.
+:
+{
+ $* a &!a;
+
+ rm a
+}
+
+: file-update
+:
+: Test that existing file touch doesn't fail.
+:
+{
+ cat <'' >=a;
+
+ $* a
+}
+
+: callback
+:
+: Test that the callback is not called for touching an existing file.
+:
+{
+ test.options += -c;
+
+ $* a >>/~%EOO% &a;
+ %create .+/a true%
+ %create .+/a false%
+ EOO
+
+ $* >>/~%EOO% a
+ %create .+/a true%
+ %create .+/a false%
+ EOO
+}
+
+: unknown-option
+:
+$* -u 2>"touch: unknown option '-u'" == 1
+
+: no-args
+:
+: Test passing no arguments.
+:
+$* 2>"touch: missing file" != 0
+
+: empty-path
+:
+: Test touching an empty path.
+:
+$* '' 2>"touch: invalid path ''" != 0
+
+: dir-update
+:
+: Test touching an existing directory.
+:
+{
+ mkdir a;
+
+ $* a 2>~'%touch: cannot create/update .+: .+%' != 0
+}
+
+: after
+:
+{
+ : success
+ :
+ {
+ $* a &a;
+ $* --after a b &b
+ }
+
+ : no-value
+ :
+ $* --after 2>"touch: missing value for option '--after'" != 0
+
+ : not-exists
+ :
+ touch --after a b 2>~"%touch: cannot obtain file '.+a' modification time: .+%" != 0
+}