3 35dc4510 2019-02-04 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 35dc4510 2019-02-04 stsp # Permission to use, copy, modify, and distribute this software for any
6 35dc4510 2019-02-04 stsp # purpose with or without fee is hereby granted, provided that the above
7 35dc4510 2019-02-04 stsp # copyright notice and this permission notice appear in all copies.
9 35dc4510 2019-02-04 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 35dc4510 2019-02-04 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 35dc4510 2019-02-04 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 35dc4510 2019-02-04 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 35dc4510 2019-02-04 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 35dc4510 2019-02-04 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 35dc4510 2019-02-04 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 35dc4510 2019-02-04 stsp . ./common.sh
19 35dc4510 2019-02-04 stsp function test_status_basic {
20 35dc4510 2019-02-04 stsp local testroot=`test_init status_basic`
22 35dc4510 2019-02-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
25 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
29 35dc4510 2019-02-04 stsp echo "modified alpha" > $testroot/wt/alpha
30 35dc4510 2019-02-04 stsp echo "unversioned file" > $testroot/wt/foo
31 35dc4510 2019-02-04 stsp rm $testroot/wt/epsilon/zeta
32 14e5d4dc 2019-02-05 stsp touch $testroot/wt/beta
33 d00136be 2019-03-26 stsp echo "new file" > $testroot/wt/new
34 d00136be 2019-03-26 stsp (cd $testroot/wt && got add new >/dev/null)
36 35dc4510 2019-02-04 stsp echo 'M alpha' > $testroot/stdout.expected
37 35dc4510 2019-02-04 stsp echo '! epsilon/zeta' >> $testroot/stdout.expected
38 35dc4510 2019-02-04 stsp echo '? foo' >> $testroot/stdout.expected
39 d00136be 2019-03-26 stsp echo 'A new' >> $testroot/stdout.expected
41 35dc4510 2019-02-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
43 35dc4510 2019-02-04 stsp cmp $testroot/stdout.expected $testroot/stdout
45 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
46 35dc4510 2019-02-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
48 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
51 f02ba292 2019-02-05 stsp function test_status_subdir_no_mods {
52 f02ba292 2019-02-05 stsp local testroot=`test_init status_subdir_no_mods 1`
54 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Basic/
55 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Basic/Targets/
56 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets/AArch64.cpp
57 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets.cpp
58 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets.h
59 f02ba292 2019-02-05 stsp (cd $testroot/repo && git add .)
60 f02ba292 2019-02-05 stsp git_commit $testroot/repo -m "add subdir with files"
62 f02ba292 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
64 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
65 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
69 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
71 f02ba292 2019-02-05 stsp # This used to erroneously print:
73 f02ba292 2019-02-05 stsp # ! Basic/Targets.cpp
74 f02ba292 2019-02-05 stsp # ? Basic/Targets.cpp
75 f02ba292 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
77 f02ba292 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
79 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
80 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
82 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
85 f02ba292 2019-02-05 stsp function test_status_subdir_no_mods2 {
86 f02ba292 2019-02-05 stsp local testroot=`test_init status_subdir_no_mods2 1`
88 f02ba292 2019-02-05 stsp mkdir $testroot/repo/AST
89 f02ba292 2019-02-05 stsp touch $testroot/repo/AST/APValue.cpp
90 f02ba292 2019-02-05 stsp mkdir $testroot/repo/ASTMatchers
91 f02ba292 2019-02-05 stsp touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
92 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend
93 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/ASTConsumers.cpp
94 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend/Rewrite
95 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
96 f02ba292 2019-02-05 stsp mkdir $testroot/repo/FrontendTool
97 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/CMakeLists.txt
98 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
99 f02ba292 2019-02-05 stsp (cd $testroot/repo && git add .)
100 f02ba292 2019-02-05 stsp git_commit $testroot/repo -m "add subdir with files"
102 f02ba292 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
104 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
105 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
109 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
111 f02ba292 2019-02-05 stsp # This used to erroneously print:
113 f02ba292 2019-02-05 stsp # ! AST/APValue.cpp
114 f02ba292 2019-02-05 stsp # ? AST/APValue.cpp
115 f02ba292 2019-02-05 stsp # ! Frontend/ASTConsumers.cpp
116 f02ba292 2019-02-05 stsp # ! Frontend/Rewrite/CMakeLists.txt
117 f02ba292 2019-02-05 stsp # ? Frontend/ASTConsumers.cpp
118 f02ba292 2019-02-05 stsp # ? Frontend/Rewrite/CMakeLists.txt
119 f02ba292 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
121 f02ba292 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
123 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
124 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
126 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
129 0dbc2271 2019-02-05 stsp function test_status_obstructed {
130 0dbc2271 2019-02-05 stsp local testroot=`test_init status_obstructed`
132 0dbc2271 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
134 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
135 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
139 0dbc2271 2019-02-05 stsp rm $testroot/wt/epsilon/zeta
140 0dbc2271 2019-02-05 stsp mkdir $testroot/wt/epsilon/zeta
142 0dbc2271 2019-02-05 stsp echo '~ epsilon/zeta' > $testroot/stdout.expected
144 0dbc2271 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
146 0dbc2271 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
148 0dbc2271 2019-02-05 stsp if [ "$?" != "0" ]; then
149 0dbc2271 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
151 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
154 02c07007 2019-02-10 stsp function test_status_shows_local_mods_after_update {
155 02c07007 2019-02-10 stsp local testroot=`test_init status_shows_local_mods_after_update 1`
157 02c07007 2019-02-10 stsp echo "1" > $testroot/repo/numbers
158 02c07007 2019-02-10 stsp echo "2" >> $testroot/repo/numbers
159 02c07007 2019-02-10 stsp echo "3" >> $testroot/repo/numbers
160 02c07007 2019-02-10 stsp echo "4" >> $testroot/repo/numbers
161 02c07007 2019-02-10 stsp echo "5" >> $testroot/repo/numbers
162 02c07007 2019-02-10 stsp echo "6" >> $testroot/repo/numbers
163 02c07007 2019-02-10 stsp echo "7" >> $testroot/repo/numbers
164 02c07007 2019-02-10 stsp echo "8" >> $testroot/repo/numbers
165 02c07007 2019-02-10 stsp (cd $testroot/repo && git add numbers)
166 02c07007 2019-02-10 stsp git_commit $testroot/repo -m "added numbers file"
168 02c07007 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
170 02c07007 2019-02-10 stsp if [ "$ret" != "0" ]; then
171 02c07007 2019-02-10 stsp test_done "$testroot" "$ret"
175 02c07007 2019-02-10 stsp sed -i 's/2/22/' $testroot/repo/numbers
176 02c07007 2019-02-10 stsp git_commit $testroot/repo -m "modified line 2"
178 02c07007 2019-02-10 stsp # modify line 7; both changes should merge cleanly
179 02c07007 2019-02-10 stsp sed -i 's/7/77/' $testroot/wt/numbers
181 02c07007 2019-02-10 stsp echo "G numbers" > $testroot/stdout.expected
182 02c07007 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
183 02c07007 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
184 02c07007 2019-02-10 stsp echo >> $testroot/stdout.expected
186 02c07007 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
188 02c07007 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
190 02c07007 2019-02-10 stsp if [ "$ret" != "0" ]; then
191 02c07007 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
192 02c07007 2019-02-10 stsp test_done "$testroot" "$ret"
196 02c07007 2019-02-10 stsp echo 'M numbers' > $testroot/stdout.expected
198 02c07007 2019-02-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
200 02c07007 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
202 02c07007 2019-02-10 stsp if [ "$ret" != "0" ]; then
203 02c07007 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
205 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
208 18831e78 2019-02-10 stsp function test_status_unversioned_subdirs {
209 18831e78 2019-02-10 stsp local testroot=`test_init status_unversioned_subdirs 1`
211 18831e78 2019-02-10 stsp mkdir $testroot/repo/cdfs/
212 18831e78 2019-02-10 stsp touch $testroot/repo/cdfs/Makefile
213 18831e78 2019-02-10 stsp mkdir $testroot/repo/common/
214 18831e78 2019-02-10 stsp touch $testroot/repo/common/Makefile
215 18831e78 2019-02-10 stsp mkdir $testroot/repo/iso/
216 18831e78 2019-02-10 stsp touch $testroot/repo/iso/Makefile
217 18831e78 2019-02-10 stsp mkdir $testroot/repo/ramdisk/
218 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk/Makefile
219 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk/list.local
220 18831e78 2019-02-10 stsp mkdir $testroot/repo/ramdisk_cd/
221 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk_cd/Makefile
222 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk_cd/list.local
223 18831e78 2019-02-10 stsp (cd $testroot/repo && git add .)
224 18831e78 2019-02-10 stsp git_commit $testroot/repo -m "first commit"
226 18831e78 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
228 18831e78 2019-02-10 stsp if [ "$ret" != "0" ]; then
229 18831e78 2019-02-10 stsp test_done "$testroot" "$ret"
233 18831e78 2019-02-10 stsp mkdir $testroot/wt/cdfs/obj
234 18831e78 2019-02-10 stsp mkdir $testroot/wt/ramdisk/obj
235 18831e78 2019-02-10 stsp mkdir $testroot/wt/ramdisk_cd/obj
236 18831e78 2019-02-10 stsp mkdir $testroot/wt/iso/obj
238 18831e78 2019-02-10 stsp echo -n > $testroot/stdout.expected
240 18831e78 2019-02-10 stsp # This used to erroneously print:
242 18831e78 2019-02-10 stsp # ! ramdisk_cd/Makefile
243 18831e78 2019-02-10 stsp # ! ramdisk_cd/list.local
244 18831e78 2019-02-10 stsp # ? ramdisk_cd/Makefile
245 18831e78 2019-02-10 stsp # ? ramdisk_cd/list.local
246 18831e78 2019-02-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
248 18831e78 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
250 18831e78 2019-02-10 stsp if [ "$ret" != "0" ]; then
251 18831e78 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
253 18831e78 2019-02-10 stsp test_done "$testroot" "$ret"
256 2c201a36 2019-02-10 stsp # 'got status' ignores symlinks at present; this might change eventually
257 2c201a36 2019-02-10 stsp function test_status_ignores_symlink {
258 2c201a36 2019-02-10 stsp local testroot=`test_init status_ignores_symlink 1`
260 2c201a36 2019-02-10 stsp mkdir $testroot/repo/ramdisk/
261 2c201a36 2019-02-10 stsp touch $testroot/repo/ramdisk/Makefile
262 2c201a36 2019-02-10 stsp (cd $testroot/repo && git add .)
263 2c201a36 2019-02-10 stsp git_commit $testroot/repo -m "first commit"
265 2c201a36 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
267 2c201a36 2019-02-10 stsp if [ "$ret" != "0" ]; then
268 2c201a36 2019-02-10 stsp test_done "$testroot" "$ret"
272 2c201a36 2019-02-10 stsp ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
274 3cbbd752 2019-02-19 stsp echo -n > $testroot/stdout.expected
276 3cbbd752 2019-02-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
278 3cbbd752 2019-02-19 stsp cmp $testroot/stdout.expected $testroot/stdout
280 3cbbd752 2019-02-19 stsp if [ "$ret" != "0" ]; then
281 3cbbd752 2019-02-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
283 3cbbd752 2019-02-19 stsp test_done "$testroot" "$ret"
286 3cbbd752 2019-02-19 stsp function test_status_shows_no_mods_after_complete_merge {
287 3cbbd752 2019-02-19 stsp local testroot=`test_init status_shows_no_mods_after_complete_merge 1`
289 3cbbd752 2019-02-19 stsp # make this file larger than the usual blob buffer size of 8192
290 3cbbd752 2019-02-19 stsp echo -n > $testroot/repo/numbers
291 3cbbd752 2019-02-19 stsp for i in `jot 16384`; do
292 3cbbd752 2019-02-19 stsp echo "$i" >> $testroot/repo/numbers
295 3cbbd752 2019-02-19 stsp (cd $testroot/repo && git add numbers)
296 3cbbd752 2019-02-19 stsp git_commit $testroot/repo -m "added numbers file"
298 3cbbd752 2019-02-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
300 3cbbd752 2019-02-19 stsp if [ "$ret" != "0" ]; then
301 3cbbd752 2019-02-19 stsp test_done "$testroot" "$ret"
305 3cbbd752 2019-02-19 stsp sed -i 's/2/22/' $testroot/repo/numbers
306 3cbbd752 2019-02-19 stsp git_commit $testroot/repo -m "modified line 2"
309 3cbbd752 2019-02-19 stsp # modify line 2 again; no local changes are left after merge
310 3cbbd752 2019-02-19 stsp sed -i 's/2/22/' $testroot/wt/numbers
312 3cbbd752 2019-02-19 stsp echo "G numbers" > $testroot/stdout.expected
313 3cbbd752 2019-02-19 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
314 3cbbd752 2019-02-19 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
315 3cbbd752 2019-02-19 stsp echo >> $testroot/stdout.expected
317 3cbbd752 2019-02-19 stsp (cd $testroot/wt && got update > $testroot/stdout)
319 3cbbd752 2019-02-19 stsp cmp $testroot/stdout.expected $testroot/stdout
321 3cbbd752 2019-02-19 stsp if [ "$ret" != "0" ]; then
322 3cbbd752 2019-02-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
323 3cbbd752 2019-02-19 stsp test_done "$testroot" "$ret"
327 2c201a36 2019-02-10 stsp echo -n > $testroot/stdout.expected
329 2c201a36 2019-02-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
331 2c201a36 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
333 2c201a36 2019-02-10 stsp if [ "$ret" != "0" ]; then
334 2c201a36 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
336 2c201a36 2019-02-10 stsp test_done "$testroot" "$ret"
339 35dc4510 2019-02-04 stsp run_test test_status_basic
340 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods
341 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods2
342 0dbc2271 2019-02-05 stsp run_test test_status_obstructed
343 02c07007 2019-02-10 stsp run_test test_status_shows_local_mods_after_update
344 18831e78 2019-02-10 stsp run_test test_status_unversioned_subdirs
345 2c201a36 2019-02-10 stsp run_test test_status_ignores_symlink
346 3cbbd752 2019-02-19 stsp run_test test_status_shows_no_mods_after_complete_merge