aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script/builtin/rm.test
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-12-31 03:14:50 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-01-05 15:30:49 +0300
commitb917233d4b618d587f569706d8d528b051efdba4 (patch)
tree1ff132a7299cb962a5be4be3a4b0fadeea2141f3 /tests/test/script/builtin/rm.test
parente1837dc7da78055ab3e355c3e941a7415146c1b8 (diff)
Tests cleanup
Diffstat (limited to 'tests/test/script/builtin/rm.test')
-rw-r--r--tests/test/script/builtin/rm.test41
1 files changed, 34 insertions, 7 deletions
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 <<EOI;
rm '' 2>"rm: invalid path ''" == 1
+EOI
+$b
: file
:
: Removing existing file succeeds.
:
+$c <<EOI;
touch a &!a;
rm a
+EOI
+$b
: file-not-exists
:
@@ -36,36 +44,49 @@ rm a
: 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 <<EOI;
rm a 2>>~%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 <<EOI;
mkdir a;
rm a 2>"rm: '$normalize([path] $~/a)' is a directory" == 1
+EOI
+$b
: dir-recursive
:
: Removing directory succeeds with -r option.
:
+$c <<EOI;
mkdir -p a/b &!a &!a/b;
rm -r a
+EOI
+$b
: scope-dir
:
: Removing scope directory fails.
:
+$c <<EOI;
rm -r ./ 2>"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 <<EOI;
+rm ../../a/b/c 2>>~%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