From b917233d4b618d587f569706d8d528b051efdba4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 31 Dec 2016 03:14:50 +0300 Subject: Tests cleanup --- tests/test/script/builtin/cat.test | 40 ++++++++++++++++++++++++----------- tests/test/script/builtin/mkdir.test | 30 ++++++++++++++++++++++---- tests/test/script/builtin/rm.test | 41 ++++++++++++++++++++++++++++++------ tests/test/script/builtin/touch.test | 27 ++++++++++++++++++++---- 4 files changed, 111 insertions(+), 27 deletions(-) (limited to 'tests/test/script/builtin') diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test index 5049ca9..20cdb86 100644 --- a/tests/test/script/builtin/cat.test +++ b/tests/test/script/builtin/cat.test @@ -2,66 +2,82 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -# @@ I think these should be run indirectly (via cat & build) -# for cross-testing to work (we want to run the via the build -# system we built, not the one we used to acomplish this. +.include ../common.test : in : -cat <>EOO +$c <>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : dash : -cat - <>EOO +$c <>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : file : -cat <>>out; +$c <>>out; foo bar -EOI +EOF cat out >>EOO foo bar EOO +EOI +$b : in-repeat : -cat - <>EOO +$c <>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : non-existent : : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <>~%EOE% != 0 -%cat: unable to print '.+[/\\]test[/\\]cat[/\\]non-existent[/\\]in': .+% +%cat: unable to print '.+[/\\]test[/\\]cat[/\\]non-existent[/\\]test[/\\]1[/\\]in': .+% %%? EOE +EOI +$b : empty-path : : Cat an empty path. : +$c <"cat: invalid path ''" == 1 +EOI +$b # @@ When piping is ready test cat on a big file to test it is asynchronous. # diff --git a/tests/test/script/builtin/mkdir.test b/tests/test/script/builtin/mkdir.test index dafcd35..07b6090 100644 --- a/tests/test/script/builtin/mkdir.test +++ b/tests/test/script/builtin/mkdir.test @@ -2,38 +2,54 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file +.include ../common.test + : dirs : +$c <"mkdir: missing directory" == 1 +$c <'mkdir 2>"mkdir: missing directory" == 1'; +$b : empty-path : : Test creation of empty directory path. : +$c <"mkdir: invalid path ''" == 1 +EOI +$b : already-exists : @@ -42,10 +58,13 @@ mkdir '' 2>"mkdir: invalid path ''" == 1 : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <>~%EOE% == 1 -%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]already-exists[/\\]a': .+% +%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]already-exists[/\\]test[/\\]1[/\\]a': .+% %%? EOE +EOI +$b : not-exists : @@ -54,7 +73,10 @@ EOE : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <>~%EOE% == 1 -%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]not-exists[/\\]a[/\\]b': .+% +%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]not-exists[/\\]test[/\\]1[/\\]a[/\\]b': .+% %%? EOE +EOI +$b diff --git a/tests/test/script/builtin/rm.test b/tests/test/script/builtin/rm.test index 20b2b24..9a18de1 100644 --- a/tests/test/script/builtin/rm.test +++ b/tests/test/script/builtin/rm.test @@ -2,32 +2,40 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -td = $~ +.include ../common.test : no-args : : Removing with no arguments fails. : -rm 2>"rm: missing file" == 1 +$c <'rm 2>"rm: missing file" == 1'; +$b : no-args-force : : Removing with no arguments succeeds with -f option. : -rm -f +$c <'rm -f'; +$b : empty-path : : Removing an empty path fails. : +$c <"rm: invalid path ''" == 1 +EOI +$b : file : : Removing existing file succeeds. : +$c <>~%EOE% == 1 -%rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file-not-exists[/\\]a': .+% +%rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file-not-exists[/\\]test[/\\]1[/\\]a': .+% %%? EOE +EOI +$b : file-not-exists-force : : Removing non-existing file succeeds with -f option. : -rm -f a +$c <'rm -f a'; +$b : dir : : Removing directory fails by default. : +$c <"rm: '$normalize([path] $~/a)' is a directory" == 1 +EOI +$b : dir-recursive : : Removing directory succeeds with -r option. : +$c <"rm: '([string] $~)' contains test working directory '$~'" == 1 +EOI +$b : outside-scope : @@ -73,7 +94,12 @@ rm -r ./ 2>"rm: '([string] $~)' contains test working directory '$~'" == 1 : path that unlikely exists (not to remove something useful). : : -rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is out of working directory '$td'" == 1 +$c <>~%EOE% == 1 +%rm: '.+[/\\]outside-scope[/\\]a[/\\]b[/\\]c' is out of working directory '.+[/\\]outside-scope[/\\]test'% +EOE +EOI +$b : outside-scope-force : @@ -81,4 +107,5 @@ rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is out of working dire : option. Need to use a path that unlikely exists (not to remove something : useful). : -rm -f ../../a/b/c +$c <'rm -f ../../a/b/c'; +$b diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test index da9ed91..3aa0271 100644 --- a/tests/test/script/builtin/touch.test +++ b/tests/test/script/builtin/touch.test @@ -2,54 +2,73 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file +.include ../common.test + : file : -touch a +$c <'touch a'; +$b : file-create : : Test that file is created. If it didn't then 'rm' would fail. : +$c <>>a; touch a +EOI +$b : no-cleanup : -: Test that touching an existing file doesn't register cleanup. If it does then +: Test that touches an existing file doesn't register cleanup. If it does then : the file would be removed while leaving the embedded scope, and so the : cleanup registered by the first touch would fail. : +$c <"touch: missing file" == 1 +$c <'touch 2>"touch: missing file" == 1'; +$b : empty-path : : Test touching an empty path. : +$c <"touch: invalid path ''" == 1 +EOI +$b : dir-update : : Test touching an existing directory. : +$c <"touch: '$a' exists and is not a file" a == 1 +touch a 2>"touch: '$a' exists and is not a file" == 1 +EOI +$b -- cgit v1.1