4 # Some tests for 'darcs mv'
6 ## I would use the builtin !, but that has the wrong semantics.
7 not
() { "$@" && exit 1 ||
:; }
9 # darcs does not support cygwin paths (/cygdrive/c/foo), so if
10 # we want to run the test suite under Cygwin Bash, we must
13 if uname |
grep -i cygwin
> /dev
/null
; then
27 echo adding a directory with
more than one ..
in it should work.
30 mkdir foo.d
/second
/third
34 touch .
/foo.d
/other
/date.t
39 darcs
mv ..
/..
/other
/date.t ..
/..
/other
/date_moved.t
42 echo darcs refuses to move to an existing
file
46 not darcs
mv ping pong
&> out
48 grep 'already exists' out
50 # case sensitivity series
51 # -----------------------
52 # these are tests designed to check out darcs behave wrt to renames
53 # where the case of the file becomes important
55 # are we on a case sensitive file system?
59 if test -e is_it_cs
; then
60 echo This is a case-sensitive
file system.
62 echo This is NOT a case-sensitive
file system.
65 # if the new file already exists - we don't allow it
66 # basically the same test as mv ping pong, except we do mv ping PING
67 # and both ping and PING exist on the filesystem
68 echo "case sensitivity - simply don't allow mv if new file exists"
69 touch 'cs-n-1'; touch 'CS-N-1';
70 touch 'cs-y-1'; touch 'CS-Y-1';
71 darcs add cs-n-1 cs-y-1
73 if test -e is_it_cs
; then
74 # regardless of case-ok, we do NOT want this mv at all
75 not darcs
mv cs-n-1 CS-Y-1
&> out
77 grep 'already exists' out
79 not darcs
mv --case-ok cs-n-1 CS-Y-1
&> out
81 grep 'already exists' out
84 # if the new file does not already exist - we allow it
85 echo "case sensitivity - the new file does *not* exist"
88 darcs add cs-n-2 cs-y-2
89 # these mv's should be allowed regardless of flag or filesystem
90 darcs
mv cs-n-2 CS-N-2
91 darcs
mv --case-ok cs-y-2 CS-Y-2
93 # parasites - do not accidentally overwrite a file just because it has a
94 # similar name and points to the same inode. We want to check if a file if the
95 # same NAME already exists - we shouldn't care about what the actual file is!
96 echo "case sensitivity - inode check";
99 darcs add cs-n-3 cs-y-3
101 if ln cs-n-3 CS-N-3
; then # checking if we support hard links
103 # regardless of case-ok, we do NOT want this mv at all
104 not darcs
mv cs-n-3 CS-N-3
&> out
106 grep 'already exists' out
108 not darcs
mv --case-ok cs-y-3 CS-Y-3
&> out
110 grep 'already exists' out
113 # parasites - we don't allow weird stuff like mv foo bar/foo just because
114 # we opened up some crazy exception based on foo's name
115 echo 'refuses to move to an existing file with same name, different path'
116 touch 'cs-n-4'; touch 'foo.d/cs-n-4';
117 touch 'cs-y-4'; touch 'foo.d/cs-y-4';
119 # regardless of case-ok, we do NOT want this mv at all
120 not darcs
mv cs-n-4 foo.d
/cs-n-4
&> out
122 grep 'already exists' out
124 not darcs
mv --case-ok cs-y-4 foo.d
/cs-y-4
&> out
126 grep 'already exists' out
128 # ---------------------------
129 # end case sensitivity series
134 REPO_ABS
=`portable_pwd`
135 darcs
mv "$REPO_ABS/abs_path.t" abs_path_new.t
136 darcs
mv abs_path_new.t
"$REPO_ABS/abs_path.t"
141 touch 'gonna_be_deleted';
142 darcs add gonna_be_deleted
143 darcs record
-am 'added doomed file'
145 darcs record
-am 'deleted file'
148 darcs
mv new_file gonna_be_deleted