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 49c543a6 2022-03-31 naddy ret=$?
24 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
36 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
47 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
57 49c543a6 2022-03-31 naddy 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 dbb83fbd 2019-12-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
65 49c543a6 2022-03-31 naddy ret=$?
66 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
67 dbb83fbd 2019-12-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
68 dbb83fbd 2019-12-12 stsp fi
69 723c305c 2019-05-11 jcs test_done "$testroot" "$ret"
70 723c305c 2019-05-11 jcs }
71 723c305c 2019-05-11 jcs
72 f6cae3ed 2020-09-13 naddy test_add_multiple() {
73 723c305c 2019-05-11 jcs local testroot=`test_init multiple_add`
74 723c305c 2019-05-11 jcs
75 723c305c 2019-05-11 jcs got checkout $testroot/repo $testroot/wt > /dev/null
76 49c543a6 2022-03-31 naddy ret=$?
77 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
78 723c305c 2019-05-11 jcs test_done "$testroot" "$ret"
79 723c305c 2019-05-11 jcs return 1
80 5c99ca9f 2019-03-27 stsp fi
81 723c305c 2019-05-11 jcs
82 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/foo
83 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/bar
84 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/baz
85 2b01eb6c 2019-05-11 stsp (cd $testroot/wt && got add foo bar baz > $testroot/stdout)
86 49c543a6 2022-03-31 naddy ret=$?
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 723c305c 2019-05-11 jcs echo "got add failed unexpectedly" >&2
89 723c305c 2019-05-11 jcs test_done "$testroot" 1
90 723c305c 2019-05-11 jcs return 1
91 723c305c 2019-05-11 jcs fi
92 723c305c 2019-05-11 jcs
93 10a623df 2021-10-11 stsp echo "A bar" > $testroot/stdout.expected
94 2b01eb6c 2019-05-11 stsp echo "A baz" >> $testroot/stdout.expected
95 10a623df 2021-10-11 stsp echo "A foo" >> $testroot/stdout.expected
96 58e5e037 2023-06-20 stsp
97 58e5e037 2023-06-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
98 58e5e037 2023-06-20 stsp ret=$?
99 58e5e037 2023-06-20 stsp if [ $ret -ne 0 ]; then
100 58e5e037 2023-06-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
101 58e5e037 2023-06-20 stsp test_done "$testroot" "$ret"
102 58e5e037 2023-06-20 stsp return 1
103 58e5e037 2023-06-20 stsp fi
104 58e5e037 2023-06-20 stsp
105 58e5e037 2023-06-20 stsp echo "new file" > $testroot/wt/bax
106 58e5e037 2023-06-20 stsp (cd $testroot/wt && got add -R * > $testroot/stdout)
107 58e5e037 2023-06-20 stsp ret=$?
108 58e5e037 2023-06-20 stsp if [ $ret -ne 0 ]; then
109 58e5e037 2023-06-20 stsp echo "got add failed unexpectedly" >&2
110 58e5e037 2023-06-20 stsp test_done "$testroot" 1
111 58e5e037 2023-06-20 stsp return 1
112 58e5e037 2023-06-20 stsp fi
113 58e5e037 2023-06-20 stsp
114 58e5e037 2023-06-20 stsp echo "A bax" > $testroot/stdout.expected
115 2b01eb6c 2019-05-11 stsp
116 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
117 49c543a6 2022-03-31 naddy ret=$?
118 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
119 2b01eb6c 2019-05-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
120 2b01eb6c 2019-05-11 stsp fi
121 58e5e037 2023-06-20 stsp
122 5c99ca9f 2019-03-27 stsp test_done "$testroot" "$ret"
123 5c99ca9f 2019-03-27 stsp }
124 5c99ca9f 2019-03-27 stsp
125 f6cae3ed 2020-09-13 naddy test_add_file_in_new_subdir() {
126 a9fa2909 2019-07-27 stsp local testroot=`test_init add_file_in_new_subdir`
127 a9fa2909 2019-07-27 stsp
128 a9fa2909 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
129 49c543a6 2022-03-31 naddy ret=$?
130 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
131 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
132 a9fa2909 2019-07-27 stsp return 1
133 a9fa2909 2019-07-27 stsp fi
134 a9fa2909 2019-07-27 stsp
135 a9fa2909 2019-07-27 stsp mkdir -p $testroot/wt/new
136 a9fa2909 2019-07-27 stsp echo "new file" > $testroot/wt/new/foo
137 a9fa2909 2019-07-27 stsp
138 a9fa2909 2019-07-27 stsp echo 'A new/foo' > $testroot/stdout.expected
139 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got add new/foo > $testroot/stdout)
140 a9fa2909 2019-07-27 stsp
141 a9fa2909 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
142 49c543a6 2022-03-31 naddy ret=$?
143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
144 a9fa2909 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
145 a9fa2909 2019-07-27 stsp fi
146 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
147 a9fa2909 2019-07-27 stsp }
148 a9fa2909 2019-07-27 stsp
149 f6cae3ed 2020-09-13 naddy test_add_deleted() {
150 6d022e97 2019-08-04 stsp local testroot=`test_init add_deleted`
151 6d022e97 2019-08-04 stsp
152 6d022e97 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
153 49c543a6 2022-03-31 naddy ret=$?
154 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
155 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
156 6d022e97 2019-08-04 stsp return 1
157 6d022e97 2019-08-04 stsp fi
158 6d022e97 2019-08-04 stsp
159 6d022e97 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
160 6d022e97 2019-08-04 stsp
161 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
162 6d022e97 2019-08-04 stsp (cd $testroot/wt && got add beta > $testroot/stdout 2> $testroot/stderr)
163 49c543a6 2022-03-31 naddy ret=$?
164 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
165 6d022e97 2019-08-04 stsp echo "got add command succeeded unexpectedly" >&2
166 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
167 6d022e97 2019-08-04 stsp test_done "$testroot" "1"
168 6d022e97 2019-08-04 stsp return 1
169 6d022e97 2019-08-04 stsp fi
170 6d022e97 2019-08-04 stsp
171 6d022e97 2019-08-04 stsp echo "got: beta: file has unexpected status" > $testroot/stderr.expected
172 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
173 49c543a6 2022-03-31 naddy ret=$?
174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
175 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
176 6d022e97 2019-08-04 stsp fi
177 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
178 6d022e97 2019-08-04 stsp }
179 6d022e97 2019-08-04 stsp
180 f6cae3ed 2020-09-13 naddy test_add_directory() {
181 4e68cba3 2019-11-23 stsp local testroot=`test_init add_directory`
182 4e68cba3 2019-11-23 stsp
183 4e68cba3 2019-11-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
184 49c543a6 2022-03-31 naddy ret=$?
185 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
186 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
187 4e68cba3 2019-11-23 stsp return 1
188 4e68cba3 2019-11-23 stsp fi
189 4e68cba3 2019-11-23 stsp
190 4e68cba3 2019-11-23 stsp (cd $testroot/wt && got add . > $testroot/stdout 2> $testroot/stderr)
191 49c543a6 2022-03-31 naddy ret=$?
192 022fae89 2019-12-06 tracey echo "got: adding directories requires -R option" \
193 022fae89 2019-12-06 tracey > $testroot/stderr.expected
194 022fae89 2019-12-06 tracey cmp -s $testroot/stderr.expected $testroot/stderr
195 49c543a6 2022-03-31 naddy ret=$?
196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
197 022fae89 2019-12-06 tracey diff -u $testroot/stderr.expected $testroot/stderr
198 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
199 4e68cba3 2019-11-23 stsp return 1
200 4e68cba3 2019-11-23 stsp fi
201 022fae89 2019-12-06 tracey
202 022fae89 2019-12-06 tracey (cd $testroot/wt && got add -I . > $testroot/stdout 2> $testroot/stderr)
203 49c543a6 2022-03-31 naddy ret=$?
204 ff56836b 2021-07-08 stsp echo "got: adding directories requires -R option" \
205 4e68cba3 2019-11-23 stsp > $testroot/stderr.expected
206 4e68cba3 2019-11-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
207 49c543a6 2022-03-31 naddy ret=$?
208 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
209 4e68cba3 2019-11-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
210 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
211 4e68cba3 2019-11-23 stsp return 1
212 4e68cba3 2019-11-23 stsp fi
213 4e68cba3 2019-11-23 stsp
214 4e68cba3 2019-11-23 stsp echo -n > $testroot/stdout.expected
215 4e68cba3 2019-11-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
216 49c543a6 2022-03-31 naddy ret=$?
217 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
218 4e68cba3 2019-11-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
219 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
220 4e68cba3 2019-11-23 stsp return 1
221 4e68cba3 2019-11-23 stsp fi
222 4e68cba3 2019-11-23 stsp
223 022fae89 2019-12-06 tracey mkdir -p $testroot/wt/tree1
224 022fae89 2019-12-06 tracey mkdir -p $testroot/wt/tree2
225 022fae89 2019-12-06 tracey echo "tree1/**" > $testroot/wt/.gitignore
226 022fae89 2019-12-06 tracey echo "tree2/**" >> $testroot/wt/.gitignore
227 022fae89 2019-12-06 tracey echo -n > $testroot/wt/tree1/foo
228 022fae89 2019-12-06 tracey echo -n > $testroot/wt/tree2/foo
229 022fae89 2019-12-06 tracey echo -n > $testroot/wt/epsilon/zeta1
230 022fae89 2019-12-06 tracey echo -n > $testroot/wt/epsilon/zeta2
231 4e68cba3 2019-11-23 stsp
232 4e68cba3 2019-11-23 stsp (cd $testroot/wt && got add -R . > $testroot/stdout)
233 4e68cba3 2019-11-23 stsp
234 022fae89 2019-12-06 tracey echo 'A .gitignore' > $testroot/stdout.expected
235 022fae89 2019-12-06 tracey echo 'A epsilon/zeta1' >> $testroot/stdout.expected
236 4e68cba3 2019-11-23 stsp echo 'A epsilon/zeta2' >> $testroot/stdout.expected
237 4e68cba3 2019-11-23 stsp
238 4e68cba3 2019-11-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
239 49c543a6 2022-03-31 naddy ret=$?
240 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
241 4e68cba3 2019-11-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
242 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
243 4e68cba3 2019-11-23 stsp return 1
244 4e68cba3 2019-11-23 stsp fi
245 4e68cba3 2019-11-23 stsp
246 022fae89 2019-12-06 tracey (cd $testroot/wt && got add -RI tree1 > $testroot/stdout)
247 4e68cba3 2019-11-23 stsp
248 022fae89 2019-12-06 tracey echo 'A tree1/foo' > $testroot/stdout.expected
249 022fae89 2019-12-06 tracey
250 022fae89 2019-12-06 tracey cmp -s $testroot/stdout.expected $testroot/stdout
251 49c543a6 2022-03-31 naddy ret=$?
252 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
253 022fae89 2019-12-06 tracey diff -u $testroot/stdout.expected $testroot/stdout
254 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
255 022fae89 2019-12-06 tracey return 1
256 4e68cba3 2019-11-23 stsp fi
257 022fae89 2019-12-06 tracey
258 022fae89 2019-12-06 tracey (cd $testroot/wt && got add tree2/foo > $testroot/stdout)
259 ff56836b 2021-07-08 stsp
260 ff56836b 2021-07-08 stsp echo -n '' > $testroot/stdout.expected
261 ff56836b 2021-07-08 stsp
262 ff56836b 2021-07-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 49c543a6 2022-03-31 naddy ret=$?
264 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
265 ff56836b 2021-07-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 ff56836b 2021-07-08 stsp test_done "$testroot" "$ret"
267 ff56836b 2021-07-08 stsp return 1
268 ff56836b 2021-07-08 stsp fi
269 022fae89 2019-12-06 tracey
270 ff56836b 2021-07-08 stsp (cd $testroot/wt && got add -I tree2/foo > $testroot/stdout)
271 ff56836b 2021-07-08 stsp
272 022fae89 2019-12-06 tracey echo 'A tree2/foo' > $testroot/stdout.expected
273 e7303626 2020-05-14 stsp
274 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
275 49c543a6 2022-03-31 naddy ret=$?
276 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
277 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
278 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
279 e7303626 2020-05-14 stsp return 1
280 e7303626 2020-05-14 stsp fi
281 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
282 e7303626 2020-05-14 stsp }
283 e7303626 2020-05-14 stsp
284 f6cae3ed 2020-09-13 naddy test_add_clashes_with_submodule() {
285 e7303626 2020-05-14 stsp local testroot=`test_init add_clashes_with_submodule`
286 e7303626 2020-05-14 stsp
287 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
288 e7303626 2020-05-14 stsp
289 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
290 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
291 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
292 e7303626 2020-05-14 stsp
293 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
294 e7303626 2020-05-14 stsp
295 e7303626 2020-05-14 stsp # Atttempt to add a file clashes with a submodule
296 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
297 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
298 022fae89 2019-12-06 tracey
299 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
300 e7303626 2020-05-14 stsp echo "A repo2" > $testroot/stdout.expected
301 022fae89 2019-12-06 tracey cmp -s $testroot/stdout.expected $testroot/stdout
302 49c543a6 2022-03-31 naddy ret=$?
303 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
304 022fae89 2019-12-06 tracey diff -u $testroot/stdout.expected $testroot/stdout
305 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
306 022fae89 2019-12-06 tracey return 1
307 022fae89 2019-12-06 tracey fi
308 e7303626 2020-05-14 stsp
309 e7303626 2020-05-14 stsp # Update for good measure; see the error below.
310 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > /dev/null)
311 e7303626 2020-05-14 stsp
312 e7303626 2020-05-14 stsp # This currently fails with "work tree must be updated"...
313 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' \
314 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
315 49c543a6 2022-03-31 naddy ret=$?
316 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
317 e7303626 2020-05-14 stsp echo "commit succeeded unexpectedly" >&2
318 e7303626 2020-05-14 stsp test_done "$testroot" "1"
319 e7303626 2020-05-14 stsp return 1
320 e7303626 2020-05-14 stsp fi
321 e7303626 2020-05-14 stsp
322 e7303626 2020-05-14 stsp echo -n "got: work tree must be updated " > $testroot/stderr.expected
323 e7303626 2020-05-14 stsp echo "before these changes can be committed" >> $testroot/stderr.expected
324 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
325 49c543a6 2022-03-31 naddy ret=$?
326 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
327 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
328 00bb5ea0 2020-07-23 stsp fi
329 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
330 00bb5ea0 2020-07-23 stsp }
331 00bb5ea0 2020-07-23 stsp
332 f6cae3ed 2020-09-13 naddy test_add_symlink() {
333 00bb5ea0 2020-07-23 stsp local testroot=`test_init add_symlink`
334 00bb5ea0 2020-07-23 stsp
335 00bb5ea0 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
336 49c543a6 2022-03-31 naddy ret=$?
337 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
338 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
339 00bb5ea0 2020-07-23 stsp return 1
340 00bb5ea0 2020-07-23 stsp fi
341 00bb5ea0 2020-07-23 stsp
342 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
343 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
344 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
345 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
346 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
347 00bb5ea0 2020-07-23 stsp
348 00bb5ea0 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
349 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add alpha.link > $testroot/stdout)
350 49c543a6 2022-03-31 naddy ret=$?
351 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
352 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
353 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
354 00bb5ea0 2020-07-23 stsp return 1
355 00bb5ea0 2020-07-23 stsp fi
356 00bb5ea0 2020-07-23 stsp
357 00bb5ea0 2020-07-23 stsp echo "A epsilon.link" > $testroot/stdout.expected
358 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add epsilon.link > $testroot/stdout)
359 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
360 49c543a6 2022-03-31 naddy ret=$?
361 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
362 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
363 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
364 00bb5ea0 2020-07-23 stsp return 1
365 e7303626 2020-05-14 stsp fi
366 00bb5ea0 2020-07-23 stsp
367 00bb5ea0 2020-07-23 stsp echo "A passwd.link" > $testroot/stdout.expected
368 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > $testroot/stdout)
369 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
370 49c543a6 2022-03-31 naddy ret=$?
371 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
372 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
373 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
374 00bb5ea0 2020-07-23 stsp return 1
375 00bb5ea0 2020-07-23 stsp fi
376 00bb5ea0 2020-07-23 stsp
377 00bb5ea0 2020-07-23 stsp echo "A epsilon/beta.link" > $testroot/stdout.expected
378 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add epsilon/beta.link > $testroot/stdout)
379 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
380 49c543a6 2022-03-31 naddy ret=$?
381 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
382 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
383 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
384 00bb5ea0 2020-07-23 stsp return 1
385 00bb5ea0 2020-07-23 stsp fi
386 00bb5ea0 2020-07-23 stsp
387 00bb5ea0 2020-07-23 stsp echo "A nonexistent.link" > $testroot/stdout.expected
388 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add nonexistent.link > $testroot/stdout)
389 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
390 49c543a6 2022-03-31 naddy ret=$?
391 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
392 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
393 00bb5ea0 2020-07-23 stsp fi
394 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
395 4e68cba3 2019-11-23 stsp }
396 4e68cba3 2019-11-23 stsp
397 7fb414ae 2020-08-08 stsp test_parseargs "$@"
398 6dbf1e9e 2019-03-26 stsp run_test test_add_basic
399 5c99ca9f 2019-03-27 stsp run_test test_double_add
400 2b01eb6c 2019-05-11 stsp run_test test_add_multiple
401 a9fa2909 2019-07-27 stsp run_test test_add_file_in_new_subdir
402 6d022e97 2019-08-04 stsp run_test test_add_deleted
403 4e68cba3 2019-11-23 stsp run_test test_add_directory
404 e7303626 2020-05-14 stsp run_test test_add_clashes_with_submodule
405 00bb5ea0 2020-07-23 stsp run_test test_add_symlink