diff options
Diffstat (limited to 'tests/builtin/touch.testscript')
-rw-r--r-- | tests/builtin/touch.testscript | 92 |
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 +} |