From 7cf026b8989a71a0d0e775e21e697ba9f1bee987 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 30 Jan 2017 23:31:45 +0300 Subject: Move builtin and runner tests to '$c ... && $b' pattern --- tests/test/script/builtin/cat.test | 31 +++++++++++++++++-------------- tests/test/script/builtin/echo.test | 18 ++++++++++++++---- tests/test/script/builtin/mkdir.test | 24 ++++++++---------------- tests/test/script/builtin/rm.test | 33 +++++++++++---------------------- tests/test/script/builtin/rmdir.test | 33 +++++++++++---------------------- tests/test/script/builtin/test.test | 30 ++++++++++-------------------- tests/test/script/builtin/touch.test | 21 +++++++-------------- 7 files changed, 78 insertions(+), 112 deletions(-) (limited to 'tests/test/script/builtin') diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test index 442ef00..33515bc 100644 --- a/tests/test/script/builtin/cat.test +++ b/tests/test/script/builtin/cat.test @@ -6,7 +6,7 @@ : in : -$c <>EOO foo bar @@ -15,11 +15,10 @@ foo bar EOO EOI -$b : dash : -$c <>EOO foo bar @@ -28,11 +27,10 @@ foo bar EOO EOI -$b : file : -$c <=out; foo bar @@ -42,11 +40,10 @@ foo bar EOO EOI -$b : in-repeat : -$c <>EOO foo bar @@ -55,25 +52,31 @@ foo bar EOO EOI -$b : non-existent : -$c <>/~%EOE% != 0 %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. -# +: big +: +: Cat a big file (about 3MB) to test that the builtin is asynchronous. +: +{ + s="------------------------------------------------------------------------" + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" + $c <"cat <'$s' | cat >'$s'" && $b +} diff --git a/tests/test/script/builtin/echo.test b/tests/test/script/builtin/echo.test index 967e330..9e49a91 100644 --- a/tests/test/script/builtin/echo.test +++ b/tests/test/script/builtin/echo.test @@ -6,10 +6,20 @@ : string : -$c <'echo foo >foo'; -$b +$c <'echo foo >foo' && $b : strings : -$c <'echo foo bar >"foo bar"'; -$b +$c <'echo foo bar >"foo bar"' && $b + +: big +: +: Echo a big string (about 3MB) to test that the builtin is asynchronous. +: +{ + s="------------------------------------------------------------------------" + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" + $c <"echo '$s' | cat >'$s'" && $b +} diff --git a/tests/test/script/builtin/mkdir.test b/tests/test/script/builtin/mkdir.test index ace4012..8f97fe3 100644 --- a/tests/test/script/builtin/mkdir.test +++ b/tests/test/script/builtin/mkdir.test @@ -6,69 +6,61 @@ : dirs : -$c <"mkdir: missing directory" == 1'; -$b +$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 : : Test creation of an existing directory. : -$c <>/~%EOE% == 1 %mkdir: unable to create directory '.+/test/mkdir/already-exists/test/1/a': .+% EOE EOI -$b : not-exists : : Test creation of a directory with non-existent parent. : -$c <>/~%EOE% == 1 %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 937633b..9a9ffc6 100644 --- a/tests/test/script/builtin/rm.test +++ b/tests/test/script/builtin/rm.test @@ -11,15 +11,13 @@ : : Removing with no arguments fails. : - $c <'rm 2>"rm: missing file" == 1'; - $b + $c <'rm 2>"rm: missing file" == 1' && $b : force : : Removing with no arguments succeeds with -f option. : - $c <'rm -f'; - $b + $c <'rm -f' && $b } : file @@ -29,11 +27,10 @@ : : Removing existing file succeeds. : - $c <>/~%EOE% == 1 %rm: unable to remove '.+/file/not-exists/fail/test/1/a': .+% EOE EOI - $b : force : : Removing non-existing file succeeds with -f option. : - $c <'rm -f a'; - $b + $c <'rm -f a' && $b } } @@ -65,30 +60,27 @@ : : Removing directory fails by default. : - $c <"rm: '$normalize([path] $~/a)' is a directory" == 1 EOI - $b : recursive : : Removing directory succeeds with -r option. : - $c <"rm: '([string] $~)' contains test working directory '$~'" == 1 EOI - $b } : path @@ -98,10 +90,9 @@ : : Removing an empty path fails. : - $c <"rm: invalid path ''" == 1 EOI - $b : outside-scope : @@ -112,19 +103,17 @@ : : Removing path outside the testscript working directory fails. : - $c <>/~%EOE% == 1 %rm: '.+/path/outside-scope/fail/a/b/c' is out of working directory '.+/path/outside-scope/fail/test'% EOE EOI - $b : force : : Removing path outside the testscript working directory succeeds with -f : option. : - $c <'rm -f ../../a/b/c'; - $b + $c <'rm -f ../../a/b/c' && $b } } diff --git a/tests/test/script/builtin/rmdir.test b/tests/test/script/builtin/rmdir.test index 7621425..6666f79 100644 --- a/tests/test/script/builtin/rmdir.test +++ b/tests/test/script/builtin/rmdir.test @@ -11,15 +11,13 @@ : : Removing with no arguments fails. : - $c <'rmdir 2>"rmdir: missing directory" == 1'; - $b + $c <'rmdir 2>"rmdir: missing directory" == 1' && $b : force : : Removing with no arguments succeeds with -f option. : - $c <'rmdir -f'; - $b + $c <'rmdir -f' && $b } : dir @@ -29,19 +27,17 @@ : : Removing an empty path fails. : - $c <"rmdir: invalid path ''" == 1 EOI - $b : test-scope : : Removing scope directory fails. : - $c <"rmdir: '$~' contains test working directory '$~'" == 1 EOI - $b : outside-scope : @@ -52,31 +48,28 @@ : : Removing directory outside the testscript working directory fails. : - $c <>/~%EOE% == 1 %rmdir: '.+/dir/outside-scope/fail/a/b/c' is out of working directory '.+/dir/outside-scope/fail/test'% EOE EOI - $b : force : : Removing path outside the testscript working directory succeeds with -f : option. : - $c <'rmdir -f ../../a/b/c'; - $b + $c <'rmdir -f ../../a/b/c' && $b } : exists : : Removing existing directory succeeds. : - $c <>/~%EOE% == 1 %rmdir: unable to remove '.+/dir/not-exists/fail/test/1/a': .+% EOE EOI - $b : force : : Removing non-existing directory succeeds with -f option. : - $c <'rmdir -f a'; - $b + $c <'rmdir -f a' && $b } : not-empty : : Removing non-empty directory fails. : - $c <>/~%EOE% == 1 %rmdir: unable to remove '.+/dir/not-empty/test/1/a': .+% EOE EOI - $b : not-dir : : Removing not a directory path fails. : - $c <>/~%EOE% == 1 %rmdir: unable to remove '.+/dir/not-dir/test/1/a': .+% EOE EOI - $b } diff --git a/tests/test/script/builtin/test.test b/tests/test/script/builtin/test.test index 7e9ace4..2e792ad 100644 --- a/tests/test/script/builtin/test.test +++ b/tests/test/script/builtin/test.test @@ -9,21 +9,18 @@ { : exists : - $c <"test: missing path" == 2'; -$b +$c <'test 2>"test: missing path" == 2' && $b : invalid-option : : Test passing invalid option. : -$c <'test -c a 2>"test: invalid option" == 2'; -$b +$c <'test -c a 2>"test: invalid option" == 2' && $b : unexpected-arg : : Test passing extra argument. : -$c <'test -f a b 2>"test: unexpected argument" == 2'; -$b +$c <'test -f a b 2>"test: unexpected argument" == 2' && $b : empty-path : : Test testing an empty path. : -$c <"test: invalid path ''" == 2 EOI -$b diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test index b3a043e..3a543e8 100644 --- a/tests/test/script/builtin/touch.test +++ b/tests/test/script/builtin/touch.test @@ -6,28 +6,25 @@ : file : -$c <'touch a'; -$b +$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 : @@ -35,7 +32,7 @@ $b : 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'; -$b +$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" == 1 EOI -$b -- cgit v1.1