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/touch.testscript | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tests/builtin/touch.testscript (limited to 'tests/builtin/touch.testscript') 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 +} -- cgit v1.1