Blame


1 2ec1f75b 2019-03-26 stsp #!/bin/sh
2 2ec1f75b 2019-03-26 stsp #
3 2ec1f75b 2019-03-26 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 2ec1f75b 2019-03-26 stsp #
5 2ec1f75b 2019-03-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 2ec1f75b 2019-03-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 2ec1f75b 2019-03-26 stsp # copyright notice and this permission notice appear in all copies.
8 2ec1f75b 2019-03-26 stsp #
9 2ec1f75b 2019-03-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 2ec1f75b 2019-03-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 2ec1f75b 2019-03-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 2ec1f75b 2019-03-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 2ec1f75b 2019-03-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 2ec1f75b 2019-03-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 2ec1f75b 2019-03-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 2ec1f75b 2019-03-26 stsp
17 2ec1f75b 2019-03-26 stsp . ./common.sh
18 2ec1f75b 2019-03-26 stsp
19 f6cae3ed 2020-09-13 naddy test_rm_basic() {
20 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_basic`
21 2ec1f75b 2019-03-26 stsp
22 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 49c543a6 2022-03-31 naddy ret=$?
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
26 2ec1f75b 2019-03-26 stsp return 1
27 2ec1f75b 2019-03-26 stsp fi
28 2ec1f75b 2019-03-26 stsp
29 17ed4618 2019-06-02 stsp echo 'D alpha' > $testroot/stdout.expected
30 17ed4618 2019-06-02 stsp echo 'D beta' >> $testroot/stdout.expected
31 17ed4618 2019-06-02 stsp (cd $testroot/wt && got rm alpha beta > $testroot/stdout)
32 2ec1f75b 2019-03-26 stsp
33 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
34 49c543a6 2022-03-31 naddy ret=$?
35 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
36 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
37 17ed4618 2019-06-02 stsp test_done "$testroot" "$ret"
38 17ed4618 2019-06-02 stsp return 1
39 2ec1f75b 2019-03-26 stsp fi
40 2ec1f75b 2019-03-26 stsp
41 17ed4618 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
42 17ed4618 2019-06-02 stsp
43 17ed4618 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
44 49c543a6 2022-03-31 naddy ret=$?
45 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
46 17ed4618 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
47 17ed4618 2019-06-02 stsp test_done "$testroot" "$ret"
48 2ec1f75b 2019-03-26 stsp return 1
49 2ec1f75b 2019-03-26 stsp fi
50 2ec1f75b 2019-03-26 stsp
51 17ed4618 2019-06-02 stsp for f in alpha beta; do
52 17ed4618 2019-06-02 stsp if [ -e $testroot/wt/$f ]; then
53 17ed4618 2019-06-02 stsp echo "removed file $f still exists on disk" >&2
54 17ed4618 2019-06-02 stsp test_done "$testroot" "1"
55 17ed4618 2019-06-02 stsp return 1
56 17ed4618 2019-06-02 stsp fi
57 17ed4618 2019-06-02 stsp done
58 17ed4618 2019-06-02 stsp
59 17ed4618 2019-06-02 stsp test_done "$testroot" "0"
60 2ec1f75b 2019-03-26 stsp }
61 2ec1f75b 2019-03-26 stsp
62 f6cae3ed 2020-09-13 naddy test_rm_with_local_mods() {
63 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_with_local_mods`
64 2ec1f75b 2019-03-26 stsp
65 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
66 49c543a6 2022-03-31 naddy ret=$?
67 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
68 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
69 2ec1f75b 2019-03-26 stsp return 1
70 2ec1f75b 2019-03-26 stsp fi
71 2ec1f75b 2019-03-26 stsp
72 2ec1f75b 2019-03-26 stsp echo "modified beta" > $testroot/wt/beta
73 f0b0c0ce 2019-08-04 stsp echo 'got: beta: file contains modifications' \
74 f0b0c0ce 2019-08-04 stsp > $testroot/stderr.expected
75 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm beta 2>$testroot/stderr)
76 2ec1f75b 2019-03-26 stsp
77 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
78 49c543a6 2022-03-31 naddy ret=$?
79 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
80 2ec1f75b 2019-03-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
81 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
82 2ec1f75b 2019-03-26 stsp return 1
83 2ec1f75b 2019-03-26 stsp fi
84 2ec1f75b 2019-03-26 stsp
85 2ec1f75b 2019-03-26 stsp echo 'D beta' > $testroot/stdout.expected
86 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm -f beta > $testroot/stdout)
87 2ec1f75b 2019-03-26 stsp
88 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
89 49c543a6 2022-03-31 naddy ret=$?
90 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
91 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
92 2ec1f75b 2019-03-26 stsp fi
93 2ec1f75b 2019-03-26 stsp
94 2ec1f75b 2019-03-26 stsp if [ -e $testroot/wt/beta ]; then
95 2ec1f75b 2019-03-26 stsp echo "removed file beta still exists on disk" >&2
96 2ec1f75b 2019-03-26 stsp test_done "$testroot" "1"
97 2ec1f75b 2019-03-26 stsp return 1
98 2ec1f75b 2019-03-26 stsp fi
99 2ec1f75b 2019-03-26 stsp
100 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
101 2ec1f75b 2019-03-26 stsp }
102 2ec1f75b 2019-03-26 stsp
103 f6cae3ed 2020-09-13 naddy test_double_rm() {
104 71a29355 2019-03-27 stsp local testroot=`test_init double_rm`
105 71a29355 2019-03-27 stsp
106 71a29355 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
107 49c543a6 2022-03-31 naddy ret=$?
108 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
109 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
110 71a29355 2019-03-27 stsp return 1
111 71a29355 2019-03-27 stsp fi
112 71a29355 2019-03-27 stsp
113 71a29355 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
114 71a29355 2019-03-27 stsp
115 71a29355 2019-03-27 stsp for fflag in "" "-f"; do
116 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
117 6d022e97 2019-08-04 stsp (cd $testroot/wt && got rm $fflag beta > $testroot/stdout \
118 6d022e97 2019-08-04 stsp 2> $testroot/stderr)
119 49c543a6 2022-03-31 naddy ret=$?
120 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
121 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
122 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
123 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
124 6d022e97 2019-08-04 stsp return 1
125 71a29355 2019-03-27 stsp fi
126 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
127 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
128 49c543a6 2022-03-31 naddy ret=$?
129 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
130 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
131 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
132 6d022e97 2019-08-04 stsp return 1
133 71a29355 2019-03-27 stsp fi
134 71a29355 2019-03-27 stsp done
135 71a29355 2019-03-27 stsp test_done "$testroot" "0"
136 71a29355 2019-03-27 stsp }
137 71a29355 2019-03-27 stsp
138 f6cae3ed 2020-09-13 naddy test_rm_and_add_elsewhere() {
139 f0b0c0ce 2019-08-04 stsp local testroot=`test_init rm_and_add_elsewhere`
140 f0b0c0ce 2019-08-04 stsp
141 f0b0c0ce 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
142 49c543a6 2022-03-31 naddy ret=$?
143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
144 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
145 f0b0c0ce 2019-08-04 stsp return 1
146 f0b0c0ce 2019-08-04 stsp fi
147 f0b0c0ce 2019-08-04 stsp
148 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && mv alpha epsilon/)
149 f0b0c0ce 2019-08-04 stsp
150 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
151 f0b0c0ce 2019-08-04 stsp
152 f0b0c0ce 2019-08-04 stsp echo '! alpha' > $testroot/stdout.expected
153 f0b0c0ce 2019-08-04 stsp echo '? epsilon/alpha' >> $testroot/stdout.expected
154 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
155 49c543a6 2022-03-31 naddy ret=$?
156 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
157 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
158 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
159 f0b0c0ce 2019-08-04 stsp return 1
160 f0b0c0ce 2019-08-04 stsp fi
161 f0b0c0ce 2019-08-04 stsp
162 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm alpha > $testroot/stdout 2> $testroot/stderr)
163 49c543a6 2022-03-31 naddy ret=$?
164 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
165 4e12cd97 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
166 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
167 4e12cd97 2022-01-25 stsp test_done "$testroot" "1"
168 4e12cd97 2022-01-25 stsp return 1
169 4e12cd97 2022-01-25 stsp fi
170 4e12cd97 2022-01-25 stsp
171 4e12cd97 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
172 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
173 49c543a6 2022-03-31 naddy ret=$?
174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
175 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
176 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
177 4e12cd97 2022-01-25 stsp return 1
178 4e12cd97 2022-01-25 stsp fi
179 4e12cd97 2022-01-25 stsp
180 4e12cd97 2022-01-25 stsp echo "got: alpha: No such file or directory" \
181 4e12cd97 2022-01-25 stsp > $testroot/stderr.expected
182 4e12cd97 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
183 49c543a6 2022-03-31 naddy ret=$?
184 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
185 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
186 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
187 4e12cd97 2022-01-25 stsp return 1
188 4e12cd97 2022-01-25 stsp fi
189 4e12cd97 2022-01-25 stsp
190 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm -f alpha > $testroot/stdout)
191 49c543a6 2022-03-31 naddy ret=$?
192 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
193 4e12cd97 2022-01-25 stsp echo "got rm command failed unexpectedly" >&2
194 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
196 4e12cd97 2022-01-25 stsp return 1
197 4e12cd97 2022-01-25 stsp fi
198 4e12cd97 2022-01-25 stsp
199 f0b0c0ce 2019-08-04 stsp echo 'D alpha' > $testroot/stdout.expected
200 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
201 49c543a6 2022-03-31 naddy ret=$?
202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
203 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
204 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
205 692bdcc4 2022-01-25 stsp return 1
206 692bdcc4 2022-01-25 stsp fi
207 692bdcc4 2022-01-25 stsp
208 692bdcc4 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
209 49c543a6 2022-03-31 naddy ret=$?
210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
211 692bdcc4 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
213 692bdcc4 2022-01-25 stsp return 1
214 692bdcc4 2022-01-25 stsp fi
215 692bdcc4 2022-01-25 stsp
216 692bdcc4 2022-01-25 stsp # While here, test behaviour of rm on files in unversioned status.
217 692bdcc4 2022-01-25 stsp (cd $testroot/wt && got rm epsilon/alpha > $testroot/stdout \
218 692bdcc4 2022-01-25 stsp 2> $testroot/stderr)
219 49c543a6 2022-03-31 naddy ret=$?
220 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
221 692bdcc4 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
222 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
223 692bdcc4 2022-01-25 stsp test_done "$testroot" "1"
224 692bdcc4 2022-01-25 stsp return 1
225 692bdcc4 2022-01-25 stsp fi
226 692bdcc4 2022-01-25 stsp
227 692bdcc4 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
228 692bdcc4 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
229 49c543a6 2022-03-31 naddy ret=$?
230 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
231 692bdcc4 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
232 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
233 692bdcc4 2022-01-25 stsp return 1
234 692bdcc4 2022-01-25 stsp fi
235 692bdcc4 2022-01-25 stsp
236 692bdcc4 2022-01-25 stsp echo "got: epsilon/alpha: file has unexpected status" \
237 692bdcc4 2022-01-25 stsp > $testroot/stderr.expected
238 692bdcc4 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
239 49c543a6 2022-03-31 naddy ret=$?
240 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
241 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
242 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
243 4e12cd97 2022-01-25 stsp return 1
244 4e12cd97 2022-01-25 stsp fi
245 f0b0c0ce 2019-08-04 stsp
246 692bdcc4 2022-01-25 stsp # And test the same case with -f.
247 692bdcc4 2022-01-25 stsp (cd $testroot/wt && got rm -f epsilon/alpha > $testroot/stdout \
248 692bdcc4 2022-01-25 stsp 2> $testroot/stderr)
249 49c543a6 2022-03-31 naddy ret=$?
250 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
251 692bdcc4 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
252 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
253 692bdcc4 2022-01-25 stsp test_done "$testroot" "1"
254 692bdcc4 2022-01-25 stsp return 1
255 692bdcc4 2022-01-25 stsp fi
256 692bdcc4 2022-01-25 stsp
257 692bdcc4 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
258 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
259 49c543a6 2022-03-31 naddy ret=$?
260 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
261 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 692bdcc4 2022-01-25 stsp test_done "$testroot" "$ret"
263 692bdcc4 2022-01-25 stsp return 1
264 692bdcc4 2022-01-25 stsp fi
265 692bdcc4 2022-01-25 stsp
266 692bdcc4 2022-01-25 stsp echo "got: epsilon/alpha: file has unexpected status" \
267 692bdcc4 2022-01-25 stsp > $testroot/stderr.expected
268 692bdcc4 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
269 49c543a6 2022-03-31 naddy ret=$?
270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
271 692bdcc4 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
272 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
273 f0b0c0ce 2019-08-04 stsp return 1
274 f0b0c0ce 2019-08-04 stsp fi
275 f0b0c0ce 2019-08-04 stsp
276 f0b0c0ce 2019-08-04 stsp echo 'A epsilon/alpha' > $testroot/stdout.expected
277 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got add epsilon/alpha > $testroot/stdout)
278 f0b0c0ce 2019-08-04 stsp
279 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
280 49c543a6 2022-03-31 naddy ret=$?
281 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
282 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
283 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
284 f0b0c0ce 2019-08-04 stsp return 1
285 f0b0c0ce 2019-08-04 stsp fi
286 f0b0c0ce 2019-08-04 stsp
287 f0b0c0ce 2019-08-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
288 f0b0c0ce 2019-08-04 stsp
289 f0b0c0ce 2019-08-04 stsp echo 'D alpha' > $testroot/stdout.expected
290 f0b0c0ce 2019-08-04 stsp echo 'A epsilon/alpha' >> $testroot/stdout.expected
291 f0b0c0ce 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
292 49c543a6 2022-03-31 naddy ret=$?
293 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
294 f0b0c0ce 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
295 f0b0c0ce 2019-08-04 stsp fi
296 f0b0c0ce 2019-08-04 stsp test_done "$testroot" "$ret"
297 f0b0c0ce 2019-08-04 stsp }
298 f0b0c0ce 2019-08-04 stsp
299 f6cae3ed 2020-09-13 naddy test_rm_directory() {
300 f2a9dc41 2019-12-13 tracey local testroot=`test_init rm_directory`
301 f2a9dc41 2019-12-13 tracey
302 f2a9dc41 2019-12-13 tracey got checkout $testroot/repo $testroot/wt > /dev/null
303 49c543a6 2022-03-31 naddy ret=$?
304 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
305 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
306 f2a9dc41 2019-12-13 tracey return 1
307 f2a9dc41 2019-12-13 tracey fi
308 f2a9dc41 2019-12-13 tracey
309 f2a9dc41 2019-12-13 tracey (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
310 49c543a6 2022-03-31 naddy ret=$?
311 f2a9dc41 2019-12-13 tracey echo "got: removing directories requires -R option" \
312 f2a9dc41 2019-12-13 tracey > $testroot/stderr.expected
313 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stderr.expected $testroot/stderr
314 49c543a6 2022-03-31 naddy ret=$?
315 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
316 f2a9dc41 2019-12-13 tracey diff -u $testroot/stderr.expected $testroot/stderr
317 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
318 f2a9dc41 2019-12-13 tracey return 1
319 f2a9dc41 2019-12-13 tracey fi
320 f2a9dc41 2019-12-13 tracey
321 f2a9dc41 2019-12-13 tracey echo -n > $testroot/stdout.expected
322 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
323 49c543a6 2022-03-31 naddy ret=$?
324 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
325 f2a9dc41 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
326 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
327 f2a9dc41 2019-12-13 tracey return 1
328 f2a9dc41 2019-12-13 tracey fi
329 f2a9dc41 2019-12-13 tracey
330 f2a9dc41 2019-12-13 tracey (cd $testroot/wt && got rm -R . > $testroot/stdout)
331 f2a9dc41 2019-12-13 tracey
332 f2a9dc41 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
333 f2a9dc41 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
334 f2a9dc41 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
335 f2a9dc41 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
336 f2a9dc41 2019-12-13 tracey
337 f2a9dc41 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
338 49c543a6 2022-03-31 naddy ret=$?
339 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
340 f2a9dc41 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
341 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
342 f2a9dc41 2019-12-13 tracey return 1
343 f2a9dc41 2019-12-13 tracey fi
344 f2a9dc41 2019-12-13 tracey
345 6b36edd8 2020-10-03 naddy (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
346 15341bfd 2020-03-05 tracey
347 15341bfd 2020-03-05 tracey echo -n '' > $testroot/stdout.expected
348 15341bfd 2020-03-05 tracey
349 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
350 49c543a6 2022-03-31 naddy ret=$?
351 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
352 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
353 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
354 15341bfd 2020-03-05 tracey return 1
355 15341bfd 2020-03-05 tracey fi
356 15341bfd 2020-03-05 tracey
357 6b36edd8 2020-10-03 naddy (cd $testroot/wt && ls -l | sed '/^total/d' > $testroot/stdout)
358 15341bfd 2020-03-05 tracey
359 15341bfd 2020-03-05 tracey echo -n '' > $testroot/stdout.expected
360 15341bfd 2020-03-05 tracey
361 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
362 49c543a6 2022-03-31 naddy ret=$?
363 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
364 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
365 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
366 15341bfd 2020-03-05 tracey return 1
367 15341bfd 2020-03-05 tracey fi
368 15341bfd 2020-03-05 tracey
369 f2a9dc41 2019-12-13 tracey test_done "$testroot" "$ret"
370 f2a9dc41 2019-12-13 tracey }
371 70e3e7f5 2019-12-13 tracey
372 f6cae3ed 2020-09-13 naddy test_rm_directory_keep_files() {
373 9c2e8939 2020-03-22 stsp local testroot=`test_init rm_directory_keep_files`
374 70e3e7f5 2019-12-13 tracey
375 70e3e7f5 2019-12-13 tracey got checkout $testroot/repo $testroot/wt > /dev/null
376 49c543a6 2022-03-31 naddy ret=$?
377 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
378 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
379 70e3e7f5 2019-12-13 tracey return 1
380 70e3e7f5 2019-12-13 tracey fi
381 70e3e7f5 2019-12-13 tracey
382 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got rm . > $testroot/stdout 2> $testroot/stderr)
383 49c543a6 2022-03-31 naddy ret=$?
384 70e3e7f5 2019-12-13 tracey echo "got: removing directories requires -R option" \
385 70e3e7f5 2019-12-13 tracey > $testroot/stderr.expected
386 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stderr.expected $testroot/stderr
387 49c543a6 2022-03-31 naddy ret=$?
388 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
389 70e3e7f5 2019-12-13 tracey diff -u $testroot/stderr.expected $testroot/stderr
390 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
391 70e3e7f5 2019-12-13 tracey return 1
392 70e3e7f5 2019-12-13 tracey fi
393 f2a9dc41 2019-12-13 tracey
394 70e3e7f5 2019-12-13 tracey echo -n > $testroot/stdout.expected
395 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
396 49c543a6 2022-03-31 naddy ret=$?
397 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
398 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
399 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
400 70e3e7f5 2019-12-13 tracey return 1
401 70e3e7f5 2019-12-13 tracey fi
402 70e3e7f5 2019-12-13 tracey
403 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got rm -k -R . > $testroot/stdout)
404 70e3e7f5 2019-12-13 tracey
405 70e3e7f5 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
406 70e3e7f5 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
407 70e3e7f5 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
408 70e3e7f5 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
409 70e3e7f5 2019-12-13 tracey
410 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
411 49c543a6 2022-03-31 naddy ret=$?
412 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
413 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
414 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
415 70e3e7f5 2019-12-13 tracey return 1
416 70e3e7f5 2019-12-13 tracey fi
417 70e3e7f5 2019-12-13 tracey
418 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got st . > $testroot/stdout)
419 70e3e7f5 2019-12-13 tracey
420 70e3e7f5 2019-12-13 tracey echo 'D alpha' > $testroot/stdout.expected
421 70e3e7f5 2019-12-13 tracey echo 'D beta' >> $testroot/stdout.expected
422 70e3e7f5 2019-12-13 tracey echo 'D epsilon/zeta' >> $testroot/stdout.expected
423 70e3e7f5 2019-12-13 tracey echo 'D gamma/delta' >> $testroot/stdout.expected
424 70e3e7f5 2019-12-13 tracey
425 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
426 49c543a6 2022-03-31 naddy ret=$?
427 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
428 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
429 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
430 70e3e7f5 2019-12-13 tracey return 1
431 70e3e7f5 2019-12-13 tracey fi
432 70e3e7f5 2019-12-13 tracey
433 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got commit -m "keep" > /dev/null)
434 70e3e7f5 2019-12-13 tracey (cd $testroot/wt && got st . > $testroot/stdout)
435 70e3e7f5 2019-12-13 tracey
436 70e3e7f5 2019-12-13 tracey echo '? alpha' > $testroot/stdout.expected
437 70e3e7f5 2019-12-13 tracey echo '? beta' >> $testroot/stdout.expected
438 70e3e7f5 2019-12-13 tracey echo '? epsilon/zeta' >> $testroot/stdout.expected
439 70e3e7f5 2019-12-13 tracey echo '? gamma/delta' >> $testroot/stdout.expected
440 70e3e7f5 2019-12-13 tracey
441 70e3e7f5 2019-12-13 tracey cmp -s $testroot/stdout.expected $testroot/stdout
442 49c543a6 2022-03-31 naddy ret=$?
443 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
444 70e3e7f5 2019-12-13 tracey diff -u $testroot/stdout.expected $testroot/stdout
445 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
446 70e3e7f5 2019-12-13 tracey return 1
447 70e3e7f5 2019-12-13 tracey fi
448 70e3e7f5 2019-12-13 tracey
449 70e3e7f5 2019-12-13 tracey test_done "$testroot" "$ret"
450 70e3e7f5 2019-12-13 tracey }
451 70e3e7f5 2019-12-13 tracey
452 f6cae3ed 2020-09-13 naddy test_rm_subtree() {
453 15341bfd 2020-03-05 tracey local testroot=`test_init rm_subtree`
454 15341bfd 2020-03-05 tracey
455 15341bfd 2020-03-05 tracey got checkout $testroot/repo $testroot/wt > /dev/null
456 49c543a6 2022-03-31 naddy ret=$?
457 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
458 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
459 15341bfd 2020-03-05 tracey return 1
460 15341bfd 2020-03-05 tracey fi
461 15341bfd 2020-03-05 tracey
462 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/baz
463 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/bax
464 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
465 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
466 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
467 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
468 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
469 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
470 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
471 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
472 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
473 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
474 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
475 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
476 15341bfd 2020-03-05 tracey (cd $testroot/wt && got add -R epsilon >/dev/null)
477 15341bfd 2020-03-05 tracey (cd $testroot/wt && got commit -m "add subtree" >/dev/null)
478 15341bfd 2020-03-05 tracey
479 15341bfd 2020-03-05 tracey # now delete and revert the entire subtree
480 15341bfd 2020-03-05 tracey (cd $testroot/wt && got rm -R epsilon/foo >/dev/null)
481 15341bfd 2020-03-05 tracey
482 15341bfd 2020-03-05 tracey if [ -d $testroot/wt/epsilon/foo ]; then
483 15341bfd 2020-03-05 tracey echo "removed dir epsilon/foo still exists on disk" >&2
484 15341bfd 2020-03-05 tracey test_done "$testroot" "1"
485 15341bfd 2020-03-05 tracey return 1
486 15341bfd 2020-03-05 tracey fi
487 15341bfd 2020-03-05 tracey
488 15341bfd 2020-03-05 tracey echo "D epsilon/foo/a.o" > $testroot/stdout.expected
489 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/b.d" >> $testroot/stdout.expected
490 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/b.o" >> $testroot/stdout.expected
491 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
492 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
493 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
494 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
495 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
496 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
497 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
498 15341bfd 2020-03-05 tracey echo "D epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
499 15341bfd 2020-03-05 tracey
500 15341bfd 2020-03-05 tracey (cd $testroot/wt && got status > $testroot/stdout)
501 a919d5c4 2020-07-23 stsp
502 a919d5c4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
503 49c543a6 2022-03-31 naddy ret=$?
504 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
505 a919d5c4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
506 a919d5c4 2020-07-23 stsp fi
507 a919d5c4 2020-07-23 stsp test_done "$testroot" "$ret"
508 a919d5c4 2020-07-23 stsp }
509 a919d5c4 2020-07-23 stsp
510 f6cae3ed 2020-09-13 naddy test_rm_symlink() {
511 a919d5c4 2020-07-23 stsp local testroot=`test_init rm_symlink`
512 a919d5c4 2020-07-23 stsp
513 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
514 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
515 a919d5c4 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
516 64773fde 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
517 64773fde 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
518 a919d5c4 2020-07-23 stsp (cd $testroot/repo && git add .)
519 64773fde 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
520 a919d5c4 2020-07-23 stsp
521 a919d5c4 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
522 49c543a6 2022-03-31 naddy ret=$?
523 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
524 a919d5c4 2020-07-23 stsp test_done "$testroot" "$ret"
525 a919d5c4 2020-07-23 stsp return 1
526 a919d5c4 2020-07-23 stsp fi
527 15341bfd 2020-03-05 tracey
528 a919d5c4 2020-07-23 stsp echo 'D alpha.link' > $testroot/stdout.expected
529 64773fde 2020-07-23 stsp echo 'D epsilon/beta.link' >> $testroot/stdout.expected
530 10a623df 2021-10-11 stsp echo 'D epsilon.link' >> $testroot/stdout.expected
531 64773fde 2020-07-23 stsp echo 'D nonexistent.link' >> $testroot/stdout.expected
532 10a623df 2021-10-11 stsp echo 'D passwd.link' >> $testroot/stdout.expected
533 64773fde 2020-07-23 stsp (cd $testroot/wt && got rm alpha.link epsilon.link passwd.link \
534 64773fde 2020-07-23 stsp epsilon/beta.link nonexistent.link > $testroot/stdout)
535 766841c2 2020-08-13 stsp
536 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
537 49c543a6 2022-03-31 naddy ret=$?
538 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
539 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
540 766841c2 2020-08-13 stsp fi
541 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
542 766841c2 2020-08-13 stsp }
543 766841c2 2020-08-13 stsp
544 f6cae3ed 2020-09-13 naddy test_rm_status_code() {
545 766841c2 2020-08-13 stsp local testroot=`test_init rm_status_code`
546 766841c2 2020-08-13 stsp
547 766841c2 2020-08-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
548 49c543a6 2022-03-31 naddy ret=$?
549 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
550 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
551 766841c2 2020-08-13 stsp return 1
552 766841c2 2020-08-13 stsp fi
553 766841c2 2020-08-13 stsp
554 766841c2 2020-08-13 stsp echo "modified beta" > $testroot/wt/beta
555 766841c2 2020-08-13 stsp
556 766841c2 2020-08-13 stsp echo "got: invalid status code 'x'" > $testroot/stderr.expected
557 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -s Mx beta 2>$testroot/stderr)
558 766841c2 2020-08-13 stsp
559 766841c2 2020-08-13 stsp cmp -s $testroot/stderr.expected $testroot/stderr
560 49c543a6 2022-03-31 naddy ret=$?
561 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
562 766841c2 2020-08-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
563 766841c2 2020-08-13 stsp test_done "$testroot" "$ret"
564 766841c2 2020-08-13 stsp return 1
565 766841c2 2020-08-13 stsp fi
566 766841c2 2020-08-13 stsp
567 766841c2 2020-08-13 stsp rm $testroot/wt/epsilon/zeta # put file into 'missing' status
568 766841c2 2020-08-13 stsp
569 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' > $testroot/stdout.expected
570 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -R -s '!' . >$testroot/stdout)
571 766841c2 2020-08-13 stsp
572 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
573 49c543a6 2022-03-31 naddy ret=$?
574 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
575 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
576 766841c2 2020-08-13 stsp fi
577 a919d5c4 2020-07-23 stsp
578 766841c2 2020-08-13 stsp if [ ! -e $testroot/wt/beta ]; then
579 766841c2 2020-08-13 stsp echo "file beta was unexpectedly removed from disk" >&2
580 766841c2 2020-08-13 stsp test_done "$testroot" "1"
581 766841c2 2020-08-13 stsp return 1
582 766841c2 2020-08-13 stsp fi
583 766841c2 2020-08-13 stsp
584 766841c2 2020-08-13 stsp # put file into 'missing' status again
585 766841c2 2020-08-13 stsp (cd $testroot/wt && got revert epsilon/zeta > /dev/null)
586 766841c2 2020-08-13 stsp rm $testroot/wt/epsilon/zeta
587 766841c2 2020-08-13 stsp
588 766841c2 2020-08-13 stsp echo 'D beta' > $testroot/stdout.expected
589 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
590 766841c2 2020-08-13 stsp (cd $testroot/wt && got rm -R -s 'M!' . >$testroot/stdout)
591 766841c2 2020-08-13 stsp
592 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
593 49c543a6 2022-03-31 naddy ret=$?
594 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
595 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
596 766841c2 2020-08-13 stsp test_done "$testroot" "1"
597 766841c2 2020-08-13 stsp return 1
598 15341bfd 2020-03-05 tracey fi
599 766841c2 2020-08-13 stsp
600 766841c2 2020-08-13 stsp if [ -e $testroot/wt/beta ]; then
601 766841c2 2020-08-13 stsp echo "removed file beta still exists on disk" >&2
602 766841c2 2020-08-13 stsp test_done "$testroot" "1"
603 766841c2 2020-08-13 stsp return 1
604 766841c2 2020-08-13 stsp fi
605 766841c2 2020-08-13 stsp
606 766841c2 2020-08-13 stsp echo 'D beta' > $testroot/stdout.expected
607 766841c2 2020-08-13 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
608 766841c2 2020-08-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
609 766841c2 2020-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
610 49c543a6 2022-03-31 naddy ret=$?
611 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
612 766841c2 2020-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
613 4e12cd97 2022-01-25 stsp test_done "$testroot" "1"
614 4e12cd97 2022-01-25 stsp return 1
615 4e12cd97 2022-01-25 stsp fi
616 4e12cd97 2022-01-25 stsp
617 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
618 4e12cd97 2022-01-25 stsp }
619 4e12cd97 2022-01-25 stsp
620 4e12cd97 2022-01-25 stsp test_rm_nonexistent_directory() {
621 4e12cd97 2022-01-25 stsp local testroot=`test_init rm_nonexistent_directory`
622 4e12cd97 2022-01-25 stsp
623 4e12cd97 2022-01-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
624 49c543a6 2022-03-31 naddy ret=$?
625 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
626 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
627 4e12cd97 2022-01-25 stsp return 1
628 4e12cd97 2022-01-25 stsp fi
629 4e12cd97 2022-01-25 stsp
630 4e12cd97 2022-01-25 stsp rm -r $testroot/wt/epsilon
631 4e12cd97 2022-01-25 stsp
632 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm epsilon > $testroot/stdout \
633 4e12cd97 2022-01-25 stsp 2> $testroot/stderr)
634 49c543a6 2022-03-31 naddy ret=$?
635 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
636 4e12cd97 2022-01-25 stsp echo "got rm command succeeded unexpectedly" >&2
637 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
638 766841c2 2020-08-13 stsp test_done "$testroot" "1"
639 766841c2 2020-08-13 stsp return 1
640 766841c2 2020-08-13 stsp fi
641 766841c2 2020-08-13 stsp
642 4e12cd97 2022-01-25 stsp echo -n '' > $testroot/stdout.expected
643 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
644 49c543a6 2022-03-31 naddy ret=$?
645 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
646 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
647 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
648 4e12cd97 2022-01-25 stsp return 1
649 4e12cd97 2022-01-25 stsp fi
650 4e12cd97 2022-01-25 stsp
651 31cf15ec 2023-04-12 stsp echo "got: epsilon/zeta: No such file or directory" \
652 4e12cd97 2022-01-25 stsp > $testroot/stderr.expected
653 4e12cd97 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
654 49c543a6 2022-03-31 naddy ret=$?
655 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
656 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
657 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
658 4e12cd97 2022-01-25 stsp return 1
659 4e12cd97 2022-01-25 stsp fi
660 4e12cd97 2022-01-25 stsp
661 4e12cd97 2022-01-25 stsp (cd $testroot/wt && got rm -f epsilon > $testroot/stdout \
662 4e12cd97 2022-01-25 stsp 2> $testroot/stderr)
663 49c543a6 2022-03-31 naddy ret=$?
664 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
665 4e12cd97 2022-01-25 stsp echo "got rm command failed unexpectedly" >&2
666 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
667 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
668 4e12cd97 2022-01-25 stsp return 1
669 4e12cd97 2022-01-25 stsp fi
670 4e12cd97 2022-01-25 stsp
671 31cf15ec 2023-04-12 stsp echo 'D epsilon/zeta' > $testroot/stdout.expected
672 4e12cd97 2022-01-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
673 49c543a6 2022-03-31 naddy ret=$?
674 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
675 4e12cd97 2022-01-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
676 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
677 4e12cd97 2022-01-25 stsp return 1
678 4e12cd97 2022-01-25 stsp fi
679 4e12cd97 2022-01-25 stsp
680 4e12cd97 2022-01-25 stsp echo -n '' > $testroot/stderr.expected
681 4e12cd97 2022-01-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
682 49c543a6 2022-03-31 naddy ret=$?
683 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
684 4e12cd97 2022-01-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
685 4e12cd97 2022-01-25 stsp test_done "$testroot" "$ret"
686 4e12cd97 2022-01-25 stsp return 1
687 4e12cd97 2022-01-25 stsp fi
688 4e12cd97 2022-01-25 stsp
689 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
690 15341bfd 2020-03-05 tracey }
691 15341bfd 2020-03-05 tracey
692 83769d30 2023-05-29 stsp test_rm_empty_pwd() {
693 83769d30 2023-05-29 stsp local testroot=`test_init rm_empty_pwd`
694 993ef5eb 2023-05-29 stsp
695 993ef5eb 2023-05-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
696 993ef5eb 2023-05-29 stsp ret=$?
697 993ef5eb 2023-05-29 stsp if [ $ret -ne 0 ]; then
698 993ef5eb 2023-05-29 stsp test_done "$testroot" "$ret"
699 993ef5eb 2023-05-29 stsp return 1
700 993ef5eb 2023-05-29 stsp fi
701 766841c2 2020-08-13 stsp
702 993ef5eb 2023-05-29 stsp (cd $testroot/wt/epsilon && got rm * > /dev/null)
703 993ef5eb 2023-05-29 stsp
704 993ef5eb 2023-05-29 stsp if [ ! -e $testroot/wt/epsilon ]; then
705 993ef5eb 2023-05-29 stsp echo "epsilon directory doesn't exist" >&2
706 993ef5eb 2023-05-29 stsp test_done "$testroot" "1"
707 993ef5eb 2023-05-29 stsp return 1
708 993ef5eb 2023-05-29 stsp fi
709 993ef5eb 2023-05-29 stsp
710 993ef5eb 2023-05-29 stsp test_done "$testroot" "0"
711 993ef5eb 2023-05-29 stsp }
712 993ef5eb 2023-05-29 stsp
713 7fb414ae 2020-08-08 stsp test_parseargs "$@"
714 2ec1f75b 2019-03-26 stsp run_test test_rm_basic
715 2ec1f75b 2019-03-26 stsp run_test test_rm_with_local_mods
716 71a29355 2019-03-27 stsp run_test test_double_rm
717 f0b0c0ce 2019-08-04 stsp run_test test_rm_and_add_elsewhere
718 f2a9dc41 2019-12-13 tracey run_test test_rm_directory
719 70e3e7f5 2019-12-13 tracey run_test test_rm_directory_keep_files
720 15341bfd 2020-03-05 tracey run_test test_rm_subtree
721 a919d5c4 2020-07-23 stsp run_test test_rm_symlink
722 766841c2 2020-08-13 stsp run_test test_rm_status_code
723 4e12cd97 2022-01-25 stsp run_test test_rm_nonexistent_directory
724 83769d30 2023-05-29 stsp run_test test_rm_empty_pwd