aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script/builtin/mv.testscript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test/script/builtin/mv.testscript')
-rw-r--r--tests/test/script/builtin/mv.testscript231
1 files changed, 66 insertions, 165 deletions
diff --git a/tests/test/script/builtin/mv.testscript b/tests/test/script/builtin/mv.testscript
index eb4860e..d703faf 100644
--- a/tests/test/script/builtin/mv.testscript
+++ b/tests/test/script/builtin/mv.testscript
@@ -4,52 +4,6 @@
.include ../common.testscript
-: unknown-option
-:
-$c <<EOI && $b
-mv -u 2>"mv: unknown option '-u'" == 1
-EOI
-
-: args
-:
-{
- : none
- :
- $c <'mv 2>"mv: missing arguments" == 1' && $b
-
- : no-source
- :
- $c <'mv a 2>"mv: missing source path" == 1' && $b
-
- : no-trailing-sep
- :
- $c <<EOI && $b
- mv a b c 2>"mv: multiple source paths without trailing separator for destination directory" == 1
- EOI
-
- : empty
- :
- {
- : dest
- :
- $c <<EOI && $b
- mv '' 2>"mv: invalid path ''" == 1
- EOI
-
- : src1
- :
- $c <<EOI && $b
- mv '' a 2>"mv: invalid path ''" == 1
- EOI
-
- : src2
- :
- $c <<EOI && $b
- mv '' a b/ 2>"mv: invalid path ''" == 1
- EOI
- }
-}
-
: synopsis-1
:
: Move an entity to the specified path.
@@ -58,43 +12,6 @@ EOI
: file
:
{
- : existing
- :
- {
- : to-non-existing
- :
- $c <<EOI && $b
- touch a;
- mv a b && test -f b && test -f a == 1
- EOI
-
- : to-existing
- :
- $c <<EOI && $b
- touch a b;
- mv a b && test -f b && test -f a == 1
- EOI
-
- : to-self
- :
- $c <<EOI && $b
- touch a;
- mv a a 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to itself%
- EOE
- EOI
-
- : to-dir
- :
- $c <<EOI && $b
- touch a;
- mkdir b;
- mv a b 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to '.+/b': .+%
- EOE
- EOI
- }
-
: outside-scope
:
: Need to use a path that unlikely exists (not to remove something useful).
@@ -105,10 +22,10 @@ EOI
: Moving path outside the testscript working directory fails.
:
$c <<EOI && $b
- mv ../../a/b/c ./c 2>>/~%EOE% == 1
- %mv: '.+/fail/a/b/c' is out of working directory '.+/fail/test'%
- EOE
- EOI
+ mv ../../a/b/c ./c 2>>/~%EOE% == 1
+ %mv: '.+/fail/a/b/c' is out of working directory '.+/fail/test'%
+ EOE
+ EOI
: force
:
@@ -117,15 +34,30 @@ EOI
: exist.
:
$c <<EOI && $b
- mv -f ../../a/b/c ./c 2>>/~%EOE% == 1
- %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+%
- EOE
- EOI
+ mv -f ../../a/b/c ./c 2>>/~%EOE% == 1
+ %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+%
+ EOE
+ EOI
}
: cleanup
:
{
+ : enabled
+ :
+ $c <<EOI && $b
+ touch a;
+ mv a b
+ EOI
+
+ : disabled
+ :
+ $c <<EOI && $b
+ touch a;
+ mv --no-cleanup a b &!a;
+ rm b
+ EOI
+
: existing
:
: Test that moving over an existing file does not move the cleanup. If
@@ -135,91 +67,60 @@ EOI
: fail.
:
$c <<EOI && $b
- +touch b
- {
- touch a;
- mv a ../b
- }
- EOI
+ +touch b
+ {
+ touch a;
+ mv a ../b
+ }
+ EOI
}
}
: dir
:
{
- : existing
+ : working-dir
:
{
- : to-non-existing
- :
- : Note the here we also test that b path is cleaned up as a directory.
- :
- $c <<EOI && $b
- mkdir a;
- mv a b && test -d b && test -d a == 1
- EOI
-
- : to-non-empty
+ : src
:
$c <<EOI && $b
- mkdir a b;
- touch b/c;
- mv a b 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to '.+/b': .+%
- EOE
- EOI
+ mv $~ b 2>"mv: '$~' contains test working directory '$~'" != 0
+ EOI
- : to-non-dir
+ : dst
:
$c <<EOI && $b
- mkdir a;
- touch b;
- mv a b 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to '.+/b': .+%
- EOE
- EOI
+ mkdir a;
+ mv a "$~" 2>"mv: '$~' contains test working directory '$~'" != 0
+ EOI
}
- : working-dir
+ : cleanup
:
{
- : src
+ : enabled
:
- {
- $c <<EOI && $b
- mv $~ b 2>"mv: '([string] $~)' contains test working directory '$~'" != 0
+ $c <<EOI && $b
+ mkdir a;
+ mv a b
EOI
- }
- : dst
+ : disabled
:
- {
- $c <<EOI && $b
+ $c <<EOI && $b
mkdir a;
- mv a "$~" 2>"mv: '$~' contains test working directory '$~'" != 0
+ mv --no-cleanup a b &!a/;
+ rm -r b
EOI
- }
- }
-
- : overlap
- :
- $c <<EOI && $b
- mkdir a;
- mv a a/b 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to '.+/a/b': .+%
- EOE
- EOI
- : cleanup
- :
- {
: sub-entry
:
- {
+ $c <<EOI && $b
mkdir a;
touch a/b;
mv a c
- }
+ EOI
: reorder
:
@@ -227,21 +128,11 @@ EOI
: it, get removed before b/ after being renamed to b/c.
:
$c <<EOI && $b
- mkdir a b;
- mv a b/c
- EOI
+ mkdir a b;
+ mv a b/c
+ EOI
}
}
-
- : non-existing
- :
- {
- $c <<EOI && $b
- mv a b 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to '.+/b': .+%
- EOE
- EOI
- }
}
: synopsis-2
@@ -249,10 +140,20 @@ EOI
: Move entities into the specified directory.
:
{
+ : cleanup
+ :
$c <<EOI && $b
- mkdir a c;
- touch a/b b;
- mv a b c/;
- test -d c/a && test -f c/a/b && test -f c/b
- EOI
+ mkdir a c;
+ touch a/b b;
+ mv a b c/
+ EOI
+
+ : no-cleanup
+ :
+ $c <<EOI && $b
+ mkdir a c;
+ touch a/b b;
+ mv --no-cleanup a b c/ &!a/ &!a/b &!b;
+ rm -r c/a/ c/b
+ EOI
}