Blame


1 6dbf1e9e 2019-03-26 stsp #!/bin/sh
2 6dbf1e9e 2019-03-26 stsp #
3 6dbf1e9e 2019-03-26 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 6dbf1e9e 2019-03-26 stsp #
5 6dbf1e9e 2019-03-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 6dbf1e9e 2019-03-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 6dbf1e9e 2019-03-26 stsp # copyright notice and this permission notice appear in all copies.
8 6dbf1e9e 2019-03-26 stsp #
9 6dbf1e9e 2019-03-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 6dbf1e9e 2019-03-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 6dbf1e9e 2019-03-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 6dbf1e9e 2019-03-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 6dbf1e9e 2019-03-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 6dbf1e9e 2019-03-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 6dbf1e9e 2019-03-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 6dbf1e9e 2019-03-26 stsp
17 6dbf1e9e 2019-03-26 stsp . ./common.sh
18 6dbf1e9e 2019-03-26 stsp
19 f6cae3ed 2020-09-13 naddy test_add_basic() {
20 6dbf1e9e 2019-03-26 stsp local testroot=`test_init add_basic`
21 6dbf1e9e 2019-03-26 stsp
22 6dbf1e9e 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fc414659 2022-04-16 thomas ret=$?
24 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
25 6dbf1e9e 2019-03-26 stsp test_done "$testroot" "$ret"
26 6dbf1e9e 2019-03-26 stsp return 1
27 6dbf1e9e 2019-03-26 stsp fi
28 6dbf1e9e 2019-03-26 stsp
29 6dbf1e9e 2019-03-26 stsp echo "new file" > $testroot/wt/foo
30 6dbf1e9e 2019-03-26 stsp
31 6dbf1e9e 2019-03-26 stsp echo 'A foo' > $testroot/stdout.expected
32 6dbf1e9e 2019-03-26 stsp (cd $testroot/wt && got add foo > $testroot/stdout)
33 6dbf1e9e 2019-03-26 stsp
34 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
35 fc414659 2022-04-16 thomas ret=$?
36 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
37 6dbf1e9e 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
38 6dbf1e9e 2019-03-26 stsp fi
39 6dbf1e9e 2019-03-26 stsp test_done "$testroot" "$ret"
40 6dbf1e9e 2019-03-26 stsp }
41 6dbf1e9e 2019-03-26 stsp
42 f6cae3ed 2020-09-13 naddy test_double_add() {
43 5c99ca9f 2019-03-27 stsp local testroot=`test_init double_add`
44 5c99ca9f 2019-03-27 stsp
45 5c99ca9f 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
46 fc414659 2022-04-16 thomas ret=$?
47 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
48 5c99ca9f 2019-03-27 stsp test_done "$testroot" "$ret"
49 5c99ca9f 2019-03-27 stsp return 1
50 5c99ca9f 2019-03-27 stsp fi
51 5c99ca9f 2019-03-27 stsp
52 5c99ca9f 2019-03-27 stsp echo "new file" > $testroot/wt/foo
53 5c99ca9f 2019-03-27 stsp (cd $testroot/wt && got add foo > /dev/null)
54 5c99ca9f 2019-03-27 stsp
55 dbb83fbd 2019-12-12 stsp (cd $testroot/wt && got add foo > $testroot/stdout)
56 fc414659 2022-04-16 thomas ret=$?
57 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
58 723c305c 2019-05-11 jcs echo "got add failed unexpectedly" >&2
59 5c99ca9f 2019-03-27 stsp test_done "$testroot" 1
60 a7c182ac 2019-03-27 stsp return 1
61 5c99ca9f 2019-03-27 stsp fi
62 5c99ca9f 2019-03-27 stsp
63 dbb83fbd 2019-12-12 stsp echo -n > $testroot/stdout.expected
64 e0d77865 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
65 e0d77865 2023-06-22 thomas ret=$?
66 e0d77865 2023-06-22 thomas if [ $ret -ne 0 ]; then
67 e0d77865 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
68 e0d77865 2023-06-22 thomas test_done "$testroot" "$ret"
69 e0d77865 2023-06-22 thomas return 1
70 e0d77865 2023-06-22 thomas fi
71 e0d77865 2023-06-22 thomas
72 e0d77865 2023-06-22 thomas echo "new file" > $testroot/wt/epsilon/zeta2
73 e0d77865 2023-06-22 thomas (cd $testroot/wt && got add epsilon/zeta* > $testroot/stdout)
74 e0d77865 2023-06-22 thomas ret=$?
75 e0d77865 2023-06-22 thomas if [ $ret -ne 0 ]; then
76 e0d77865 2023-06-22 thomas echo "got add failed unexpectedly" >&2
77 e0d77865 2023-06-22 thomas test_done "$testroot" 1
78 e0d77865 2023-06-22 thomas return 1
79 e0d77865 2023-06-22 thomas fi
80 e0d77865 2023-06-22 thomas
81 e0d77865 2023-06-22 thomas echo 'A epsilon/zeta2' > $testroot/stdout.expected
82 dbb83fbd 2019-12-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
83 fc414659 2022-04-16 thomas ret=$?
84 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
85 dbb83fbd 2019-12-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
86 dbb83fbd 2019-12-12 stsp fi
87 723c305c 2019-05-11 jcs test_done "$testroot" "$ret"
88 723c305c 2019-05-11 jcs }
89 723c305c 2019-05-11 jcs
90 f6cae3ed 2020-09-13 naddy test_add_multiple() {
91 723c305c 2019-05-11 jcs local testroot=`test_init multiple_add`
92 723c305c 2019-05-11 jcs
93 723c305c 2019-05-11 jcs got checkout $testroot/repo $testroot/wt > /dev/null
94 fc414659 2022-04-16 thomas ret=$?
95 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
96 723c305c 2019-05-11 jcs test_done "$testroot" "$ret"
97 723c305c 2019-05-11 jcs return 1
98 5c99ca9f 2019-03-27 stsp fi
99 723c305c 2019-05-11 jcs
100 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/foo
101 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/bar
102 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/baz
103 2b01eb6c 2019-05-11 stsp (cd $testroot/wt && got add foo bar baz > $testroot/stdout)
104 fc414659 2022-04-16 thomas ret=$?
105 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
106 723c305c 2019-05-11 jcs echo "got add failed unexpectedly" >&2
107 723c305c 2019-05-11 jcs test_done "$testroot" 1
108 723c305c 2019-05-11 jcs return 1
109 723c305c 2019-05-11 jcs fi
110 723c305c 2019-05-11 jcs
111 f1417e9f 2021-10-12 thomas echo "A bar" > $testroot/stdout.expected
112 2b01eb6c 2019-05-11 stsp echo "A baz" >> $testroot/stdout.expected
113 f1417e9f 2021-10-12 thomas echo "A foo" >> $testroot/stdout.expected
114 aa174d08 2023-06-22 thomas
115 aa174d08 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
116 aa174d08 2023-06-22 thomas ret=$?
117 aa174d08 2023-06-22 thomas if [ $ret -ne 0 ]; then
118 aa174d08 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
119 aa174d08 2023-06-22 thomas test_done "$testroot" "$ret"
120 aa174d08 2023-06-22 thomas return 1
121 aa174d08 2023-06-22 thomas fi
122 aa174d08 2023-06-22 thomas
123 b21ebdb0 2023-06-22 thomas echo "changed file" > $testroot/wt/alpha
124 aa174d08 2023-06-22 thomas echo "new file" > $testroot/wt/bax
125 aa174d08 2023-06-22 thomas (cd $testroot/wt && got add -R * > $testroot/stdout)
126 aa174d08 2023-06-22 thomas ret=$?
127 aa174d08 2023-06-22 thomas if [ $ret -ne 0 ]; then
128 aa174d08 2023-06-22 thomas echo "got add failed unexpectedly" >&2
129 aa174d08 2023-06-22 thomas test_done "$testroot" 1
130 aa174d08 2023-06-22 thomas return 1
131 aa174d08 2023-06-22 thomas fi
132 aa174d08 2023-06-22 thomas
133 aa174d08 2023-06-22 thomas echo "A bax" > $testroot/stdout.expected
134 2b01eb6c 2019-05-11 stsp
135 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
136 fc414659 2022-04-16 thomas ret=$?
137 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
138 2b01eb6c 2019-05-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 2b01eb6c 2019-05-11 stsp fi
140 aa174d08 2023-06-22 thomas
141 5c99ca9f 2019-03-27 stsp test_done "$testroot" "$ret"
142 5c99ca9f 2019-03-27 stsp }
143 5c99ca9f 2019-03-27 stsp
144 f6cae3ed 2020-09-13 naddy test_add_file_in_new_subdir() {
145 a9fa2909 2019-07-27 stsp local testroot=`test_init add_file_in_new_subdir`
146 a9fa2909 2019-07-27 stsp
147 a9fa2909 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
148 fc414659 2022-04-16 thomas ret=$?
149 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
150 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
151 a9fa2909 2019-07-27 stsp return 1
152 a9fa2909 2019-07-27 stsp fi
153 a9fa2909 2019-07-27 stsp
154 a9fa2909 2019-07-27 stsp mkdir -p $testroot/wt/new
155 a9fa2909 2019-07-27 stsp echo "new file" > $testroot/wt/new/foo
156 a9fa2909 2019-07-27 stsp
157 a9fa2909 2019-07-27 stsp echo 'A new/foo' > $testroot/stdout.expected
158 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got add new/foo > $testroot/stdout)
159 a9fa2909 2019-07-27 stsp
160 a9fa2909 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
161 fc414659 2022-04-16 thomas ret=$?
162 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
163 a9fa2909 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
164 a9fa2909 2019-07-27 stsp fi
165 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
166 a9fa2909 2019-07-27 stsp }
167 a9fa2909 2019-07-27 stsp
168 f6cae3ed 2020-09-13 naddy test_add_deleted() {
169 6d022e97 2019-08-04 stsp local testroot=`test_init add_deleted`
170 6d022e97 2019-08-04 stsp
171 6d022e97 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
172 fc414659 2022-04-16 thomas ret=$?
173 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
174 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
175 6d022e97 2019-08-04 stsp return 1
176 6d022e97 2019-08-04 stsp fi
177 6d022e97 2019-08-04 stsp
178 6d022e97 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
179 6d022e97 2019-08-04 stsp
180 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
181 6d022e97 2019-08-04 stsp (cd $testroot/wt && got add beta > $testroot/stdout 2> $testroot/stderr)
182 fc414659 2022-04-16 thomas ret=$?
183 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
184 6d022e97 2019-08-04 stsp echo "got add command succeeded unexpectedly" >&2
185 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
186 6d022e97 2019-08-04 stsp test_done "$testroot" "1"
187 6d022e97 2019-08-04 stsp return 1
188 6d022e97 2019-08-04 stsp fi
189 6d022e97 2019-08-04 stsp
190 6d022e97 2019-08-04 stsp echo "got: beta: file has unexpected status" > $testroot/stderr.expected
191 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
192 fc414659 2022-04-16 thomas ret=$?
193 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
194 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 6d022e97 2019-08-04 stsp fi
196 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
197 6d022e97 2019-08-04 stsp }
198 6d022e97 2019-08-04 stsp
199 f6cae3ed 2020-09-13 naddy test_add_directory() {
200 4e68cba3 2019-11-23 stsp local testroot=`test_init add_directory`
201 4e68cba3 2019-11-23 stsp
202 4e68cba3 2019-11-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
203 fc414659 2022-04-16 thomas ret=$?
204 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
205 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
206 4e68cba3 2019-11-23 stsp return 1
207 4e68cba3 2019-11-23 stsp fi
208 4e68cba3 2019-11-23 stsp
209 4e68cba3 2019-11-23 stsp (cd $testroot/wt && got add . > $testroot/stdout 2> $testroot/stderr)
210 fc414659 2022-04-16 thomas ret=$?
211 022fae89 2019-12-06 tracey echo "got: adding directories requires -R option" \
212 022fae89 2019-12-06 tracey > $testroot/stderr.expected
213 022fae89 2019-12-06 tracey cmp -s $testroot/stderr.expected $testroot/stderr
214 fc414659 2022-04-16 thomas ret=$?
215 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
216 022fae89 2019-12-06 tracey diff -u $testroot/stderr.expected $testroot/stderr
217 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
218 4e68cba3 2019-11-23 stsp return 1
219 4e68cba3 2019-11-23 stsp fi
220 022fae89 2019-12-06 tracey
221 022fae89 2019-12-06 tracey (cd $testroot/wt && got add -I . > $testroot/stdout 2> $testroot/stderr)
222 fc414659 2022-04-16 thomas ret=$?
223 ff56836b 2021-07-08 stsp echo "got: adding directories requires -R option" \
224 4e68cba3 2019-11-23 stsp > $testroot/stderr.expected
225 4e68cba3 2019-11-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
226 fc414659 2022-04-16 thomas ret=$?
227 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
228 4e68cba3 2019-11-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
229 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
230 4e68cba3 2019-11-23 stsp return 1
231 4e68cba3 2019-11-23 stsp fi
232 4e68cba3 2019-11-23 stsp
233 4e68cba3 2019-11-23 stsp echo -n > $testroot/stdout.expected
234 4e68cba3 2019-11-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
235 fc414659 2022-04-16 thomas ret=$?
236 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
237 4e68cba3 2019-11-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
238 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
239 4e68cba3 2019-11-23 stsp return 1
240 4e68cba3 2019-11-23 stsp fi
241 4e68cba3 2019-11-23 stsp
242 022fae89 2019-12-06 tracey mkdir -p $testroot/wt/tree1
243 022fae89 2019-12-06 tracey mkdir -p $testroot/wt/tree2
244 022fae89 2019-12-06 tracey echo "tree1/**" > $testroot/wt/.gitignore
245 022fae89 2019-12-06 tracey echo "tree2/**" >> $testroot/wt/.gitignore
246 022fae89 2019-12-06 tracey echo -n > $testroot/wt/tree1/foo
247 022fae89 2019-12-06 tracey echo -n > $testroot/wt/tree2/foo
248 022fae89 2019-12-06 tracey echo -n > $testroot/wt/epsilon/zeta1
249 022fae89 2019-12-06 tracey echo -n > $testroot/wt/epsilon/zeta2
250 4e68cba3 2019-11-23 stsp
251 4e68cba3 2019-11-23 stsp (cd $testroot/wt && got add -R . > $testroot/stdout)
252 4e68cba3 2019-11-23 stsp
253 022fae89 2019-12-06 tracey echo 'A .gitignore' > $testroot/stdout.expected
254 022fae89 2019-12-06 tracey echo 'A epsilon/zeta1' >> $testroot/stdout.expected
255 4e68cba3 2019-11-23 stsp echo 'A epsilon/zeta2' >> $testroot/stdout.expected
256 4e68cba3 2019-11-23 stsp
257 4e68cba3 2019-11-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
258 fc414659 2022-04-16 thomas ret=$?
259 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
260 4e68cba3 2019-11-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
261 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
262 4e68cba3 2019-11-23 stsp return 1
263 4e68cba3 2019-11-23 stsp fi
264 4e68cba3 2019-11-23 stsp
265 022fae89 2019-12-06 tracey (cd $testroot/wt && got add -RI tree1 > $testroot/stdout)
266 4e68cba3 2019-11-23 stsp
267 022fae89 2019-12-06 tracey echo 'A tree1/foo' > $testroot/stdout.expected
268 022fae89 2019-12-06 tracey
269 022fae89 2019-12-06 tracey cmp -s $testroot/stdout.expected $testroot/stdout
270 fc414659 2022-04-16 thomas ret=$?
271 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
272 022fae89 2019-12-06 tracey diff -u $testroot/stdout.expected $testroot/stdout
273 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
274 022fae89 2019-12-06 tracey return 1
275 4e68cba3 2019-11-23 stsp fi
276 022fae89 2019-12-06 tracey
277 022fae89 2019-12-06 tracey (cd $testroot/wt && got add tree2/foo > $testroot/stdout)
278 ff56836b 2021-07-08 stsp
279 ff56836b 2021-07-08 stsp echo -n '' > $testroot/stdout.expected
280 ff56836b 2021-07-08 stsp
281 ff56836b 2021-07-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
282 fc414659 2022-04-16 thomas ret=$?
283 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
284 ff56836b 2021-07-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
285 ff56836b 2021-07-08 stsp test_done "$testroot" "$ret"
286 ff56836b 2021-07-08 stsp return 1
287 ff56836b 2021-07-08 stsp fi
288 022fae89 2019-12-06 tracey
289 ff56836b 2021-07-08 stsp (cd $testroot/wt && got add -I tree2/foo > $testroot/stdout)
290 ff56836b 2021-07-08 stsp
291 022fae89 2019-12-06 tracey echo 'A tree2/foo' > $testroot/stdout.expected
292 e7303626 2020-05-14 stsp
293 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
294 fc414659 2022-04-16 thomas ret=$?
295 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
296 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
297 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
298 e7303626 2020-05-14 stsp return 1
299 e7303626 2020-05-14 stsp fi
300 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
301 e7303626 2020-05-14 stsp }
302 e7303626 2020-05-14 stsp
303 f6cae3ed 2020-09-13 naddy test_add_clashes_with_submodule() {
304 e7303626 2020-05-14 stsp local testroot=`test_init add_clashes_with_submodule`
305 e7303626 2020-05-14 stsp
306 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
307 e7303626 2020-05-14 stsp
308 bf3ab206 2022-10-24 thomas (cd $testroot/repo && git -c protocol.file.allow=always \
309 bf3ab206 2022-10-24 thomas submodule -q add ../repo2)
310 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
311 e7303626 2020-05-14 stsp
312 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
313 e7303626 2020-05-14 stsp
314 e7303626 2020-05-14 stsp # Atttempt to add a file clashes with a submodule
315 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
316 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
317 022fae89 2019-12-06 tracey
318 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
319 e7303626 2020-05-14 stsp echo "A repo2" > $testroot/stdout.expected
320 022fae89 2019-12-06 tracey cmp -s $testroot/stdout.expected $testroot/stdout
321 fc414659 2022-04-16 thomas ret=$?
322 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
323 022fae89 2019-12-06 tracey diff -u $testroot/stdout.expected $testroot/stdout
324 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
325 022fae89 2019-12-06 tracey return 1
326 022fae89 2019-12-06 tracey fi
327 e7303626 2020-05-14 stsp
328 e7303626 2020-05-14 stsp # Update for good measure; see the error below.
329 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > /dev/null)
330 e7303626 2020-05-14 stsp
331 e7303626 2020-05-14 stsp # This currently fails with "work tree must be updated"...
332 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' \
333 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
334 fc414659 2022-04-16 thomas ret=$?
335 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
336 e7303626 2020-05-14 stsp echo "commit succeeded unexpectedly" >&2
337 e7303626 2020-05-14 stsp test_done "$testroot" "1"
338 e7303626 2020-05-14 stsp return 1
339 e7303626 2020-05-14 stsp fi
340 e7303626 2020-05-14 stsp
341 e7303626 2020-05-14 stsp echo -n "got: work tree must be updated " > $testroot/stderr.expected
342 e7303626 2020-05-14 stsp echo "before these changes can be committed" >> $testroot/stderr.expected
343 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
344 fc414659 2022-04-16 thomas ret=$?
345 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
346 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
347 00bb5ea0 2020-07-23 stsp fi
348 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
349 00bb5ea0 2020-07-23 stsp }
350 00bb5ea0 2020-07-23 stsp
351 f6cae3ed 2020-09-13 naddy test_add_symlink() {
352 00bb5ea0 2020-07-23 stsp local testroot=`test_init add_symlink`
353 00bb5ea0 2020-07-23 stsp
354 00bb5ea0 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
355 fc414659 2022-04-16 thomas ret=$?
356 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
357 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
358 00bb5ea0 2020-07-23 stsp return 1
359 00bb5ea0 2020-07-23 stsp fi
360 00bb5ea0 2020-07-23 stsp
361 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
362 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
363 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
364 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
365 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
366 00bb5ea0 2020-07-23 stsp
367 00bb5ea0 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
368 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add alpha.link > $testroot/stdout)
369 fc414659 2022-04-16 thomas ret=$?
370 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
371 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
372 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
373 00bb5ea0 2020-07-23 stsp return 1
374 00bb5ea0 2020-07-23 stsp fi
375 00bb5ea0 2020-07-23 stsp
376 00bb5ea0 2020-07-23 stsp echo "A epsilon.link" > $testroot/stdout.expected
377 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add epsilon.link > $testroot/stdout)
378 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
379 fc414659 2022-04-16 thomas ret=$?
380 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
381 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
382 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
383 00bb5ea0 2020-07-23 stsp return 1
384 e7303626 2020-05-14 stsp fi
385 00bb5ea0 2020-07-23 stsp
386 00bb5ea0 2020-07-23 stsp echo "A passwd.link" > $testroot/stdout.expected
387 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > $testroot/stdout)
388 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
389 fc414659 2022-04-16 thomas ret=$?
390 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
391 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
392 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
393 00bb5ea0 2020-07-23 stsp return 1
394 00bb5ea0 2020-07-23 stsp fi
395 00bb5ea0 2020-07-23 stsp
396 00bb5ea0 2020-07-23 stsp echo "A epsilon/beta.link" > $testroot/stdout.expected
397 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add epsilon/beta.link > $testroot/stdout)
398 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
399 fc414659 2022-04-16 thomas ret=$?
400 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
401 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
402 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
403 00bb5ea0 2020-07-23 stsp return 1
404 00bb5ea0 2020-07-23 stsp fi
405 00bb5ea0 2020-07-23 stsp
406 00bb5ea0 2020-07-23 stsp echo "A nonexistent.link" > $testroot/stdout.expected
407 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add nonexistent.link > $testroot/stdout)
408 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
409 fc414659 2022-04-16 thomas ret=$?
410 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
411 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
412 00bb5ea0 2020-07-23 stsp fi
413 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
414 4e68cba3 2019-11-23 stsp }
415 4e68cba3 2019-11-23 stsp
416 7fb414ae 2020-08-08 stsp test_parseargs "$@"
417 6dbf1e9e 2019-03-26 stsp run_test test_add_basic
418 5c99ca9f 2019-03-27 stsp run_test test_double_add
419 2b01eb6c 2019-05-11 stsp run_test test_add_multiple
420 a9fa2909 2019-07-27 stsp run_test test_add_file_in_new_subdir
421 6d022e97 2019-08-04 stsp run_test test_add_deleted
422 4e68cba3 2019-11-23 stsp run_test test_add_directory
423 e7303626 2020-05-14 stsp run_test test_add_clashes_with_submodule
424 00bb5ea0 2020-07-23 stsp run_test test_add_symlink