Blame


1 fccbfb98 2019-08-03 stsp #!/bin/sh
2 fccbfb98 2019-08-03 stsp #
3 fccbfb98 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 fccbfb98 2019-08-03 stsp #
5 fccbfb98 2019-08-03 stsp # Permission to use, copy, modify, and distribute this software for any
6 fccbfb98 2019-08-03 stsp # purpose with or without fee is hereby granted, provided that the above
7 fccbfb98 2019-08-03 stsp # copyright notice and this permission notice appear in all copies.
8 fccbfb98 2019-08-03 stsp #
9 fccbfb98 2019-08-03 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 fccbfb98 2019-08-03 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 fccbfb98 2019-08-03 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 fccbfb98 2019-08-03 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 fccbfb98 2019-08-03 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 fccbfb98 2019-08-03 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 fccbfb98 2019-08-03 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 fccbfb98 2019-08-03 stsp
17 fccbfb98 2019-08-03 stsp . ./common.sh
18 fccbfb98 2019-08-03 stsp
19 fccbfb98 2019-08-03 stsp function test_stage_basic {
20 fccbfb98 2019-08-03 stsp local testroot=`test_init stage_basic`
21 fccbfb98 2019-08-03 stsp
22 fccbfb98 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fccbfb98 2019-08-03 stsp ret="$?"
24 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
25 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
26 fccbfb98 2019-08-03 stsp return 1
27 fccbfb98 2019-08-03 stsp fi
28 fccbfb98 2019-08-03 stsp
29 fccbfb98 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
30 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
31 fccbfb98 2019-08-03 stsp echo "new file" > $testroot/wt/foo
32 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
33 fccbfb98 2019-08-03 stsp
34 88d0e355 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
35 88d0e355 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
36 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
37 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
38 d3e7c587 2019-08-03 stsp
39 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
40 d3e7c587 2019-08-03 stsp ret="$?"
41 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
42 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
43 d3e7c587 2019-08-03 stsp fi
44 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
45 d3e7c587 2019-08-03 stsp }
46 d3e7c587 2019-08-03 stsp
47 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
48 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
49 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
50 ebf48fd5 2019-08-03 stsp
51 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
52 ebf48fd5 2019-08-03 stsp ret="$?"
53 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
54 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
55 ebf48fd5 2019-08-03 stsp return 1
56 ebf48fd5 2019-08-03 stsp fi
57 ebf48fd5 2019-08-03 stsp
58 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
59 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
60 ebf48fd5 2019-08-03 stsp
61 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
62 ebf48fd5 2019-08-03 stsp
63 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
64 ebf48fd5 2019-08-03 stsp
65 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
66 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
67 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
68 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
69 ebf48fd5 2019-08-03 stsp
70 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
71 ebf48fd5 2019-08-03 stsp
72 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
73 ebf48fd5 2019-08-03 stsp ret="$?"
74 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
75 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
76 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
77 ebf48fd5 2019-08-03 stsp return 1
78 ebf48fd5 2019-08-03 stsp fi
79 ebf48fd5 2019-08-03 stsp
80 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
81 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
82 ebf48fd5 2019-08-03 stsp ret="$?"
83 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
84 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
85 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
86 ebf48fd5 2019-08-03 stsp return 1
87 ebf48fd5 2019-08-03 stsp fi
88 ebf48fd5 2019-08-03 stsp
89 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
90 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
91 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
92 735ef5ac 2019-08-03 stsp
93 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
94 735ef5ac 2019-08-03 stsp ret="$?"
95 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
96 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
97 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
98 735ef5ac 2019-08-03 stsp return 1
99 735ef5ac 2019-08-03 stsp fi
100 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
101 735ef5ac 2019-08-03 stsp ret="$?"
102 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
103 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
104 735ef5ac 2019-08-03 stsp fi
105 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
106 735ef5ac 2019-08-03 stsp }
107 735ef5ac 2019-08-03 stsp
108 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
109 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
110 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
111 735ef5ac 2019-08-03 stsp
112 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
113 735ef5ac 2019-08-03 stsp ret="$?"
114 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
115 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
116 735ef5ac 2019-08-03 stsp return 1
117 735ef5ac 2019-08-03 stsp fi
118 735ef5ac 2019-08-03 stsp
119 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
120 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
121 735ef5ac 2019-08-03 stsp
122 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
123 735ef5ac 2019-08-03 stsp
124 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
125 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
126 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
127 735ef5ac 2019-08-03 stsp ret="$?"
128 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
129 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
130 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
131 735ef5ac 2019-08-03 stsp return 1
132 735ef5ac 2019-08-03 stsp fi
133 735ef5ac 2019-08-03 stsp
134 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
135 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
136 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
137 ebf48fd5 2019-08-03 stsp
138 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
139 ebf48fd5 2019-08-03 stsp ret="$?"
140 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
141 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
142 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
143 ebf48fd5 2019-08-03 stsp return 1
144 ebf48fd5 2019-08-03 stsp fi
145 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
146 ebf48fd5 2019-08-03 stsp ret="$?"
147 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
148 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
149 ebf48fd5 2019-08-03 stsp fi
150 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
151 ebf48fd5 2019-08-03 stsp }
152 ebf48fd5 2019-08-03 stsp
153 ebf48fd5 2019-08-03 stsp
154 d3e7c587 2019-08-03 stsp function test_double_stage {
155 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
156 d3e7c587 2019-08-03 stsp
157 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
158 d3e7c587 2019-08-03 stsp ret="$?"
159 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
160 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
161 d3e7c587 2019-08-03 stsp return 1
162 d3e7c587 2019-08-03 stsp fi
163 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
164 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
165 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
166 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
167 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
168 d3e7c587 2019-08-03 stsp
169 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
170 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
171 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
172 d3e7c587 2019-08-03 stsp ret="$?"
173 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
174 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
175 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
176 d3e7c587 2019-08-03 stsp return 1
177 d3e7c587 2019-08-03 stsp fi
178 d3e7c587 2019-08-03 stsp
179 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
180 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
181 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
182 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
183 d3e7c587 2019-08-03 stsp return 1
184 d3e7c587 2019-08-03 stsp fi
185 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
186 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
187 d3e7c587 2019-08-03 stsp ret="$?"
188 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
189 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
190 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
191 d3e7c587 2019-08-03 stsp return 1
192 d3e7c587 2019-08-03 stsp fi
193 d3e7c587 2019-08-03 stsp
194 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
195 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
196 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
197 d3e7c587 2019-08-03 stsp ret="$?"
198 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
199 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
200 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
201 d3e7c587 2019-08-03 stsp return 1
202 d3e7c587 2019-08-03 stsp fi
203 d3e7c587 2019-08-03 stsp
204 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
205 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
206 d3e7c587 2019-08-03 stsp
207 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
208 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
209 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
210 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
211 d3e7c587 2019-08-03 stsp ret="$?"
212 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
213 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
214 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
215 d3e7c587 2019-08-03 stsp return 1
216 d3e7c587 2019-08-03 stsp fi
217 d3e7c587 2019-08-03 stsp
218 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
219 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
220 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
221 fccbfb98 2019-08-03 stsp
222 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
223 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
224 fccbfb98 2019-08-03 stsp ret="$?"
225 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
226 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
227 fccbfb98 2019-08-03 stsp fi
228 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
229 fccbfb98 2019-08-03 stsp }
230 fccbfb98 2019-08-03 stsp
231 c363b2c1 2019-08-03 stsp function test_stage_status {
232 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
233 c363b2c1 2019-08-03 stsp
234 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
235 c363b2c1 2019-08-03 stsp ret="$?"
236 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
237 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
238 c363b2c1 2019-08-03 stsp return 1
239 c363b2c1 2019-08-03 stsp fi
240 c363b2c1 2019-08-03 stsp
241 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
242 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
243 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
244 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
245 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
246 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
247 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
248 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
249 c363b2c1 2019-08-03 stsp
250 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
251 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
252 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
253 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
254 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
255 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
256 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
257 c363b2c1 2019-08-03 stsp
258 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
259 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
260 c363b2c1 2019-08-03 stsp ret="$?"
261 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
262 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
263 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
264 244725f2 2019-08-03 stsp return 1
265 c363b2c1 2019-08-03 stsp fi
266 244725f2 2019-08-03 stsp
267 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
268 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
269 244725f2 2019-08-03 stsp
270 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
271 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
272 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
273 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
274 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
275 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
276 244725f2 2019-08-03 stsp
277 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
278 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
279 244725f2 2019-08-03 stsp ret="$?"
280 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
281 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
282 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
283 244725f2 2019-08-03 stsp return 1
284 244725f2 2019-08-03 stsp fi
285 244725f2 2019-08-03 stsp
286 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
287 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
288 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
289 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
290 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
291 244725f2 2019-08-03 stsp ret="$?"
292 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
293 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
294 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
295 244725f2 2019-08-03 stsp return 1
296 244725f2 2019-08-03 stsp fi
297 244725f2 2019-08-03 stsp
298 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
299 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
300 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
301 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
302 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
303 244725f2 2019-08-03 stsp ret="$?"
304 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
305 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
306 244725f2 2019-08-03 stsp fi
307 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
308 244725f2 2019-08-03 stsp
309 c363b2c1 2019-08-03 stsp }
310 c363b2c1 2019-08-03 stsp
311 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
312 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
313 1e1446d3 2019-08-03 stsp
314 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
315 1e1446d3 2019-08-03 stsp ret="$?"
316 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
317 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
318 1e1446d3 2019-08-03 stsp return 1
319 1e1446d3 2019-08-03 stsp fi
320 1e1446d3 2019-08-03 stsp
321 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
322 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
323 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
324 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
325 1e1446d3 2019-08-03 stsp
326 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
327 1e1446d3 2019-08-03 stsp
328 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add beta \
329 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
330 1e1446d3 2019-08-03 stsp ret="$?"
331 1e1446d3 2019-08-03 stsp if [ "$ret" == "0" ]; then
332 1e1446d3 2019-08-03 stsp echo "got add command succeeded unexpectedly" >&2
333 1e1446d3 2019-08-03 stsp test_done "$testroot" "1"
334 1e1446d3 2019-08-03 stsp return 1
335 1e1446d3 2019-08-03 stsp fi
336 1e1446d3 2019-08-03 stsp echo "got: realpath: beta: No such file or directory" \
337 1e1446d3 2019-08-03 stsp > $testroot/stderr.expected
338 1e1446d3 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
339 1e1446d3 2019-08-03 stsp ret="$?"
340 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
341 1e1446d3 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
342 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
343 1e1446d3 2019-08-03 stsp return 1
344 1e1446d3 2019-08-03 stsp fi
345 1e1446d3 2019-08-03 stsp
346 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
347 1e1446d3 2019-08-03 stsp for f in alpha foo; do
348 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
349 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
350 1e1446d3 2019-08-03 stsp ret="$?"
351 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
352 1e1446d3 2019-08-03 stsp echo "got add command failed unexpectedly" >&2
353 1e1446d3 2019-08-03 stsp test_done "$testroot" "1"
354 1e1446d3 2019-08-03 stsp return 1
355 1e1446d3 2019-08-03 stsp fi
356 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
357 1e1446d3 2019-08-03 stsp ret="$?"
358 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
359 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
360 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
361 1e1446d3 2019-08-03 stsp return 1
362 1e1446d3 2019-08-03 stsp fi
363 1e1446d3 2019-08-03 stsp done
364 1e1446d3 2019-08-03 stsp
365 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
366 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
367 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
368 1e1446d3 2019-08-03 stsp
369 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
370 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
371 1e1446d3 2019-08-03 stsp ret="$?"
372 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
373 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
374 1e1446d3 2019-08-03 stsp fi
375 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
376 1e1446d3 2019-08-03 stsp }
377 1e1446d3 2019-08-03 stsp
378 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
379 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
380 9acbc4fa 2019-08-03 stsp
381 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
382 9acbc4fa 2019-08-03 stsp ret="$?"
383 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
384 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
385 9acbc4fa 2019-08-03 stsp return 1
386 9acbc4fa 2019-08-03 stsp fi
387 9acbc4fa 2019-08-03 stsp
388 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
389 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
390 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
391 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
392 9acbc4fa 2019-08-03 stsp
393 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
394 9acbc4fa 2019-08-03 stsp
395 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
396 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
397 9acbc4fa 2019-08-03 stsp ret="$?"
398 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
399 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
400 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
401 9acbc4fa 2019-08-03 stsp return 1
402 9acbc4fa 2019-08-03 stsp fi
403 9acbc4fa 2019-08-03 stsp echo "got: realpath: beta: No such file or directory" \
404 9acbc4fa 2019-08-03 stsp > $testroot/stderr.expected
405 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
406 9acbc4fa 2019-08-03 stsp ret="$?"
407 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
408 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
409 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
410 9acbc4fa 2019-08-03 stsp return 1
411 9acbc4fa 2019-08-03 stsp fi
412 9acbc4fa 2019-08-03 stsp
413 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
414 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
415 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
416 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
417 9acbc4fa 2019-08-03 stsp ret="$?"
418 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
419 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
420 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
421 9acbc4fa 2019-08-03 stsp return 1
422 9acbc4fa 2019-08-03 stsp fi
423 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
424 9acbc4fa 2019-08-03 stsp ret="$?"
425 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
426 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
427 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
428 9acbc4fa 2019-08-03 stsp return 1
429 9acbc4fa 2019-08-03 stsp fi
430 9acbc4fa 2019-08-03 stsp done
431 9acbc4fa 2019-08-03 stsp
432 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
433 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
434 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
435 9acbc4fa 2019-08-03 stsp
436 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
437 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
438 9acbc4fa 2019-08-03 stsp ret="$?"
439 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
440 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
441 9acbc4fa 2019-08-03 stsp fi
442 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
443 9acbc4fa 2019-08-03 stsp }
444 24278f30 2019-08-03 stsp
445 24278f30 2019-08-03 stsp function test_stage_revert {
446 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
447 24278f30 2019-08-03 stsp
448 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
449 24278f30 2019-08-03 stsp ret="$?"
450 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
451 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
452 24278f30 2019-08-03 stsp return 1
453 24278f30 2019-08-03 stsp fi
454 24278f30 2019-08-03 stsp
455 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
456 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
457 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
458 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
459 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
460 24278f30 2019-08-03 stsp
461 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
462 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
463 24278f30 2019-08-03 stsp
464 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
465 24278f30 2019-08-03 stsp ret="$?"
466 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
467 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
468 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
469 24278f30 2019-08-03 stsp return 1
470 24278f30 2019-08-03 stsp fi
471 24278f30 2019-08-03 stsp
472 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
473 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
474 24278f30 2019-08-03 stsp ret="$?"
475 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
476 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
477 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
478 24278f30 2019-08-03 stsp return 1
479 24278f30 2019-08-03 stsp fi
480 24278f30 2019-08-03 stsp
481 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
482 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
483 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
484 24278f30 2019-08-03 stsp ret="$?"
485 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
486 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
487 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
488 24278f30 2019-08-03 stsp return 1
489 24278f30 2019-08-03 stsp fi
490 9acbc4fa 2019-08-03 stsp
491 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
492 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
493 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
494 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
495 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
496 24278f30 2019-08-03 stsp ret="$?"
497 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
498 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
499 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
500 24278f30 2019-08-03 stsp return 1
501 24278f30 2019-08-03 stsp fi
502 24278f30 2019-08-03 stsp
503 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
504 24278f30 2019-08-03 stsp ret="$?"
505 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
506 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
507 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
508 24278f30 2019-08-03 stsp return 1
509 24278f30 2019-08-03 stsp fi
510 24278f30 2019-08-03 stsp
511 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
512 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
513 24278f30 2019-08-03 stsp ret="$?"
514 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
515 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
516 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
517 24278f30 2019-08-03 stsp return 1
518 24278f30 2019-08-03 stsp fi
519 24278f30 2019-08-03 stsp
520 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
521 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
522 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
523 24278f30 2019-08-03 stsp ret="$?"
524 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
525 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
526 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
527 24278f30 2019-08-03 stsp return 1
528 24278f30 2019-08-03 stsp fi
529 24278f30 2019-08-03 stsp
530 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
531 24278f30 2019-08-03 stsp 2> $testroot/stderr)
532 24278f30 2019-08-03 stsp ret="$?"
533 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
534 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
535 24278f30 2019-08-03 stsp test_done "$testroot" "1"
536 24278f30 2019-08-03 stsp return 1
537 24278f30 2019-08-03 stsp fi
538 24278f30 2019-08-03 stsp
539 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
540 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
541 24278f30 2019-08-03 stsp ret="$?"
542 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
543 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
544 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
545 24278f30 2019-08-03 stsp return 1
546 24278f30 2019-08-03 stsp fi
547 24278f30 2019-08-03 stsp
548 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
549 24278f30 2019-08-03 stsp ret="$?"
550 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
551 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
552 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
553 24278f30 2019-08-03 stsp return 1
554 24278f30 2019-08-03 stsp fi
555 24278f30 2019-08-03 stsp
556 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
557 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
558 24278f30 2019-08-03 stsp ret="$?"
559 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
560 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
561 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
562 24278f30 2019-08-03 stsp return 1
563 24278f30 2019-08-03 stsp fi
564 24278f30 2019-08-03 stsp
565 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
566 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
567 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
568 24278f30 2019-08-03 stsp ret="$?"
569 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
570 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
571 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
572 24278f30 2019-08-03 stsp return 1
573 24278f30 2019-08-03 stsp fi
574 24278f30 2019-08-03 stsp
575 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
576 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
577 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
578 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
579 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
580 24278f30 2019-08-03 stsp ret="$?"
581 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
582 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
583 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
584 24278f30 2019-08-03 stsp return 1
585 24278f30 2019-08-03 stsp fi
586 24278f30 2019-08-03 stsp
587 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
588 24278f30 2019-08-03 stsp ret="$?"
589 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
590 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
591 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
592 24278f30 2019-08-03 stsp return 1
593 24278f30 2019-08-03 stsp fi
594 24278f30 2019-08-03 stsp
595 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
596 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
597 24278f30 2019-08-03 stsp ret="$?"
598 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
599 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
600 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
601 24278f30 2019-08-03 stsp return 1
602 24278f30 2019-08-03 stsp fi
603 24278f30 2019-08-03 stsp
604 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
605 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
606 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
607 24278f30 2019-08-03 stsp ret="$?"
608 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
609 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
610 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
611 24278f30 2019-08-03 stsp return 1
612 24278f30 2019-08-03 stsp fi
613 24278f30 2019-08-03 stsp
614 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
615 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
616 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
617 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
618 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
619 408b4ebc 2019-08-03 stsp ret="$?"
620 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
621 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
622 408b4ebc 2019-08-03 stsp fi
623 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
624 408b4ebc 2019-08-03 stsp }
625 408b4ebc 2019-08-03 stsp
626 408b4ebc 2019-08-03 stsp function test_stage_diff {
627 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
628 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
629 408b4ebc 2019-08-03 stsp
630 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
631 408b4ebc 2019-08-03 stsp ret="$?"
632 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
633 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
634 408b4ebc 2019-08-03 stsp return 1
635 408b4ebc 2019-08-03 stsp fi
636 408b4ebc 2019-08-03 stsp
637 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
638 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
639 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
640 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
641 98eaaa12 2019-08-03 stsp
642 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
643 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
644 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
645 98eaaa12 2019-08-03 stsp ret="$?"
646 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
647 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
648 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
649 98eaaa12 2019-08-03 stsp return 1
650 98eaaa12 2019-08-03 stsp fi
651 408b4ebc 2019-08-03 stsp
652 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
653 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
654 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
655 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
656 408b4ebc 2019-08-03 stsp
657 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
658 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
659 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
660 408b4ebc 2019-08-03 stsp ret="$?"
661 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
662 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
663 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
664 408b4ebc 2019-08-03 stsp return 1
665 408b4ebc 2019-08-03 stsp fi
666 408b4ebc 2019-08-03 stsp
667 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
668 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
669 408b4ebc 2019-08-03 stsp
670 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
671 408b4ebc 2019-08-03 stsp
672 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
673 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
674 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
675 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
676 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
677 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
678 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
679 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
680 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
681 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
682 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
683 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
684 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
685 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
686 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
687 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
688 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
689 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
690 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
691 98eaaa12 2019-08-03 stsp
692 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
693 98eaaa12 2019-08-03 stsp ret="$?"
694 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
695 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
696 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
697 98eaaa12 2019-08-03 stsp return 1
698 98eaaa12 2019-08-03 stsp fi
699 98eaaa12 2019-08-03 stsp
700 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
701 98eaaa12 2019-08-03 stsp
702 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
703 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
704 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
705 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
706 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
707 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
708 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
709 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
710 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
711 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
712 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
713 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
714 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
715 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
716 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
717 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
718 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
719 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
720 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
721 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
722 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
723 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
724 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
725 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
726 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
727 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
728 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
729 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
730 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
731 408b4ebc 2019-08-03 stsp
732 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
733 24278f30 2019-08-03 stsp ret="$?"
734 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
735 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
736 24278f30 2019-08-03 stsp fi
737 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
738 408b4ebc 2019-08-03 stsp
739 24278f30 2019-08-03 stsp }
740 b9622844 2019-08-03 stsp
741 b9622844 2019-08-03 stsp function test_stage_histedit {
742 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
743 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
744 b9622844 2019-08-03 stsp
745 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
746 b9622844 2019-08-03 stsp ret="$?"
747 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
748 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
749 b9622844 2019-08-03 stsp return 1
750 b9622844 2019-08-03 stsp fi
751 b9622844 2019-08-03 stsp
752 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
753 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
754 b9622844 2019-08-03 stsp
755 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
756 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
757 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
758 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
759 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
760 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
761 24278f30 2019-08-03 stsp
762 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
763 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
764 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
765 b9622844 2019-08-03 stsp
766 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
767 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
768 b9622844 2019-08-03 stsp
769 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
770 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
771 b9622844 2019-08-03 stsp ret="$?"
772 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
773 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
774 b9622844 2019-08-03 stsp test_done "$testroot" "1"
775 b9622844 2019-08-03 stsp return 1
776 b9622844 2019-08-03 stsp fi
777 b9622844 2019-08-03 stsp
778 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
779 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
780 b9622844 2019-08-03 stsp
781 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
782 b9622844 2019-08-03 stsp ret="$?"
783 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
784 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
785 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
786 b9622844 2019-08-03 stsp return 1
787 b9622844 2019-08-03 stsp fi
788 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
789 b9622844 2019-08-03 stsp ret="$?"
790 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
791 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
792 b9622844 2019-08-03 stsp fi
793 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
794 243d7cf1 2019-08-03 stsp
795 243d7cf1 2019-08-03 stsp }
796 243d7cf1 2019-08-03 stsp
797 243d7cf1 2019-08-03 stsp function test_stage_rebase {
798 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
799 243d7cf1 2019-08-03 stsp
800 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
801 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
802 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
803 243d7cf1 2019-08-03 stsp
804 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
805 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
806 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
807 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
808 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
809 243d7cf1 2019-08-03 stsp
810 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
811 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
812 243d7cf1 2019-08-03 stsp
813 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
814 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
815 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
816 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
817 243d7cf1 2019-08-03 stsp
818 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
819 243d7cf1 2019-08-03 stsp ret="$?"
820 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
821 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
822 243d7cf1 2019-08-03 stsp return 1
823 243d7cf1 2019-08-03 stsp fi
824 243d7cf1 2019-08-03 stsp
825 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
826 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
827 b9622844 2019-08-03 stsp
828 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
829 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
830 243d7cf1 2019-08-03 stsp ret="$?"
831 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
832 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
833 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
834 243d7cf1 2019-08-03 stsp return 1
835 243d7cf1 2019-08-03 stsp fi
836 243d7cf1 2019-08-03 stsp
837 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
838 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
839 243d7cf1 2019-08-03 stsp
840 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
841 243d7cf1 2019-08-03 stsp ret="$?"
842 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
843 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
844 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
845 243d7cf1 2019-08-03 stsp return 1
846 243d7cf1 2019-08-03 stsp fi
847 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
848 243d7cf1 2019-08-03 stsp ret="$?"
849 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
850 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
851 243d7cf1 2019-08-03 stsp fi
852 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
853 b9622844 2019-08-03 stsp }
854 b9622844 2019-08-03 stsp
855 a76c42e6 2019-08-03 stsp function test_stage_update {
856 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
857 a76c42e6 2019-08-03 stsp
858 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
859 a76c42e6 2019-08-03 stsp ret="$?"
860 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
861 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
862 a76c42e6 2019-08-03 stsp return 1
863 a76c42e6 2019-08-03 stsp fi
864 243d7cf1 2019-08-03 stsp
865 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
866 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
867 a76c42e6 2019-08-03 stsp
868 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
869 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
870 a76c42e6 2019-08-03 stsp
871 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
872 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
873 a76c42e6 2019-08-03 stsp ret="$?"
874 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
875 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
876 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
877 a76c42e6 2019-08-03 stsp return 1
878 a76c42e6 2019-08-03 stsp fi
879 a76c42e6 2019-08-03 stsp
880 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
881 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
882 a76c42e6 2019-08-03 stsp
883 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
884 a76c42e6 2019-08-03 stsp ret="$?"
885 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
886 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
887 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
888 a76c42e6 2019-08-03 stsp return 1
889 a76c42e6 2019-08-03 stsp fi
890 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
891 a76c42e6 2019-08-03 stsp ret="$?"
892 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
893 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
894 a76c42e6 2019-08-03 stsp fi
895 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
896 a76c42e6 2019-08-03 stsp }
897 a76c42e6 2019-08-03 stsp
898 fccbfb98 2019-08-03 stsp run_test test_stage_basic
899 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
900 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
901 d3e7c587 2019-08-03 stsp run_test test_double_stage
902 c363b2c1 2019-08-03 stsp run_test test_stage_status
903 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
904 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
905 24278f30 2019-08-03 stsp run_test test_stage_revert
906 408b4ebc 2019-08-03 stsp run_test test_stage_diff
907 b9622844 2019-08-03 stsp run_test test_stage_histedit
908 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
909 a76c42e6 2019-08-03 stsp run_test test_stage_update