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/rm.test | 41 ++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'tests/test/script/builtin/rm.test') 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 -- cgit v1.1