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
34 35dc4510 2019-02-04 stsp echo 'M alpha' > $testroot/stdout.expected
35 35dc4510 2019-02-04 stsp echo '! epsilon/zeta' >> $testroot/stdout.expected
36 35dc4510 2019-02-04 stsp echo '? foo' >> $testroot/stdout.expected
38 35dc4510 2019-02-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
40 35dc4510 2019-02-04 stsp cmp $testroot/stdout.expected $testroot/stdout
42 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
43 35dc4510 2019-02-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
45 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
48 f02ba292 2019-02-05 stsp function test_status_subdir_no_mods {
49 f02ba292 2019-02-05 stsp local testroot=`test_init status_subdir_no_mods 1`
51 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Basic/
52 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Basic/Targets/
53 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets/AArch64.cpp
54 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets.cpp
55 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets.h
56 f02ba292 2019-02-05 stsp (cd $testroot/repo && git add .)
57 f02ba292 2019-02-05 stsp git_commit $testroot/repo -m "add subdir with files"
59 f02ba292 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
61 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
62 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
66 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
68 f02ba292 2019-02-05 stsp # This used to erroneously print:
70 f02ba292 2019-02-05 stsp # ! Basic/Targets.cpp
71 f02ba292 2019-02-05 stsp # ? Basic/Targets.cpp
72 f02ba292 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
74 f02ba292 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
76 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
77 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
82 f02ba292 2019-02-05 stsp function test_status_subdir_no_mods2 {
83 f02ba292 2019-02-05 stsp local testroot=`test_init status_subdir_no_mods2 1`
85 f02ba292 2019-02-05 stsp mkdir $testroot/repo/AST
86 f02ba292 2019-02-05 stsp touch $testroot/repo/AST/APValue.cpp
87 f02ba292 2019-02-05 stsp mkdir $testroot/repo/ASTMatchers
88 f02ba292 2019-02-05 stsp touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
89 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend
90 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/ASTConsumers.cpp
91 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend/Rewrite
92 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
93 f02ba292 2019-02-05 stsp mkdir $testroot/repo/FrontendTool
94 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/CMakeLists.txt
95 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
96 f02ba292 2019-02-05 stsp (cd $testroot/repo && git add .)
97 f02ba292 2019-02-05 stsp git_commit $testroot/repo -m "add subdir with files"
99 f02ba292 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
101 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
102 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
106 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
108 f02ba292 2019-02-05 stsp # This used to erroneously print:
110 f02ba292 2019-02-05 stsp # ! AST/APValue.cpp
111 f02ba292 2019-02-05 stsp # ? AST/APValue.cpp
112 f02ba292 2019-02-05 stsp # ! Frontend/ASTConsumers.cpp
113 f02ba292 2019-02-05 stsp # ! Frontend/Rewrite/CMakeLists.txt
114 f02ba292 2019-02-05 stsp # ? Frontend/ASTConsumers.cpp
115 f02ba292 2019-02-05 stsp # ? Frontend/Rewrite/CMakeLists.txt
116 f02ba292 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
118 f02ba292 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
120 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
121 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
123 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
126 0dbc2271 2019-02-05 stsp function test_status_obstructed {
127 0dbc2271 2019-02-05 stsp local testroot=`test_init status_obstructed`
129 0dbc2271 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
131 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
132 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
136 0dbc2271 2019-02-05 stsp rm $testroot/wt/epsilon/zeta
137 0dbc2271 2019-02-05 stsp mkdir $testroot/wt/epsilon/zeta
139 0dbc2271 2019-02-05 stsp echo '~ epsilon/zeta' > $testroot/stdout.expected
141 0dbc2271 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
143 0dbc2271 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
145 0dbc2271 2019-02-05 stsp if [ "$?" != "0" ]; then
146 0dbc2271 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
148 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
151 02c07007 2019-02-10 stsp function test_status_shows_local_mods_after_update {
152 02c07007 2019-02-10 stsp local testroot=`test_init status_shows_local_mods_after_update 1`
154 02c07007 2019-02-10 stsp echo "1" > $testroot/repo/numbers
155 02c07007 2019-02-10 stsp echo "2" >> $testroot/repo/numbers
156 02c07007 2019-02-10 stsp echo "3" >> $testroot/repo/numbers
157 02c07007 2019-02-10 stsp echo "4" >> $testroot/repo/numbers
158 02c07007 2019-02-10 stsp echo "5" >> $testroot/repo/numbers
159 02c07007 2019-02-10 stsp echo "6" >> $testroot/repo/numbers
160 02c07007 2019-02-10 stsp echo "7" >> $testroot/repo/numbers
161 02c07007 2019-02-10 stsp echo "8" >> $testroot/repo/numbers
162 02c07007 2019-02-10 stsp (cd $testroot/repo && git add numbers)
163 02c07007 2019-02-10 stsp git_commit $testroot/repo -m "added numbers file"
165 02c07007 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
167 02c07007 2019-02-10 stsp if [ "$ret" != "0" ]; then
168 02c07007 2019-02-10 stsp test_done "$testroot" "$ret"
172 02c07007 2019-02-10 stsp sed -i 's/2/22/' $testroot/repo/numbers
173 02c07007 2019-02-10 stsp git_commit $testroot/repo -m "modified line 2"
175 02c07007 2019-02-10 stsp # modify line 7; both changes should merge cleanly
176 02c07007 2019-02-10 stsp sed -i 's/7/77/' $testroot/wt/numbers
178 02c07007 2019-02-10 stsp echo "G numbers" > $testroot/stdout.expected
179 02c07007 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
180 02c07007 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
181 02c07007 2019-02-10 stsp echo >> $testroot/stdout.expected
183 02c07007 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
185 02c07007 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
187 02c07007 2019-02-10 stsp if [ "$ret" != "0" ]; then
188 02c07007 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
189 02c07007 2019-02-10 stsp test_done "$testroot" "$ret"
193 02c07007 2019-02-10 stsp echo 'M numbers' > $testroot/stdout.expected
195 02c07007 2019-02-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
197 02c07007 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
199 02c07007 2019-02-10 stsp if [ "$ret" != "0" ]; then
200 02c07007 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
202 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
205 18831e78 2019-02-10 stsp function test_status_unversioned_subdirs {
206 18831e78 2019-02-10 stsp local testroot=`test_init status_unversioned_subdirs 1`
208 18831e78 2019-02-10 stsp mkdir $testroot/repo/cdfs/
209 18831e78 2019-02-10 stsp touch $testroot/repo/cdfs/Makefile
210 18831e78 2019-02-10 stsp mkdir $testroot/repo/common/
211 18831e78 2019-02-10 stsp touch $testroot/repo/common/Makefile
212 18831e78 2019-02-10 stsp mkdir $testroot/repo/iso/
213 18831e78 2019-02-10 stsp touch $testroot/repo/iso/Makefile
214 18831e78 2019-02-10 stsp mkdir $testroot/repo/ramdisk/
215 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk/Makefile
216 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk/list.local
217 18831e78 2019-02-10 stsp mkdir $testroot/repo/ramdisk_cd/
218 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk_cd/Makefile
219 18831e78 2019-02-10 stsp touch $testroot/repo/ramdisk_cd/list.local
220 18831e78 2019-02-10 stsp (cd $testroot/repo && git add .)
221 18831e78 2019-02-10 stsp git_commit $testroot/repo -m "first commit"
223 18831e78 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
225 18831e78 2019-02-10 stsp if [ "$ret" != "0" ]; then
226 18831e78 2019-02-10 stsp test_done "$testroot" "$ret"
230 18831e78 2019-02-10 stsp mkdir $testroot/wt/cdfs/obj
231 18831e78 2019-02-10 stsp mkdir $testroot/wt/ramdisk/obj
232 18831e78 2019-02-10 stsp mkdir $testroot/wt/ramdisk_cd/obj
233 18831e78 2019-02-10 stsp mkdir $testroot/wt/iso/obj
235 18831e78 2019-02-10 stsp echo -n > $testroot/stdout.expected
237 18831e78 2019-02-10 stsp # This used to erroneously print:
239 18831e78 2019-02-10 stsp # ! ramdisk_cd/Makefile
240 18831e78 2019-02-10 stsp # ! ramdisk_cd/list.local
241 18831e78 2019-02-10 stsp # ? ramdisk_cd/Makefile
242 18831e78 2019-02-10 stsp # ? ramdisk_cd/list.local
243 18831e78 2019-02-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
245 18831e78 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
247 18831e78 2019-02-10 stsp if [ "$ret" != "0" ]; then
248 18831e78 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
250 18831e78 2019-02-10 stsp test_done "$testroot" "$ret"
253 2c201a36 2019-02-10 stsp # 'got status' ignores symlinks at present; this might change eventually
254 2c201a36 2019-02-10 stsp function test_status_ignores_symlink {
255 2c201a36 2019-02-10 stsp local testroot=`test_init status_ignores_symlink 1`
257 2c201a36 2019-02-10 stsp mkdir $testroot/repo/ramdisk/
258 2c201a36 2019-02-10 stsp touch $testroot/repo/ramdisk/Makefile
259 2c201a36 2019-02-10 stsp (cd $testroot/repo && git add .)
260 2c201a36 2019-02-10 stsp git_commit $testroot/repo -m "first commit"
262 2c201a36 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
264 2c201a36 2019-02-10 stsp if [ "$ret" != "0" ]; then
265 2c201a36 2019-02-10 stsp test_done "$testroot" "$ret"
269 2c201a36 2019-02-10 stsp ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
271 3cbbd752 2019-02-19 stsp echo -n > $testroot/stdout.expected
273 3cbbd752 2019-02-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
275 3cbbd752 2019-02-19 stsp cmp $testroot/stdout.expected $testroot/stdout
277 3cbbd752 2019-02-19 stsp if [ "$ret" != "0" ]; then
278 3cbbd752 2019-02-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
280 3cbbd752 2019-02-19 stsp test_done "$testroot" "$ret"
283 3cbbd752 2019-02-19 stsp function test_status_shows_no_mods_after_complete_merge {
284 3cbbd752 2019-02-19 stsp local testroot=`test_init status_shows_no_mods_after_complete_merge 1`
286 3cbbd752 2019-02-19 stsp # make this file larger than the usual blob buffer size of 8192
287 3cbbd752 2019-02-19 stsp echo -n > $testroot/repo/numbers
288 3cbbd752 2019-02-19 stsp for i in `jot 16384`; do
289 3cbbd752 2019-02-19 stsp echo "$i" >> $testroot/repo/numbers
292 3cbbd752 2019-02-19 stsp (cd $testroot/repo && git add numbers)
293 3cbbd752 2019-02-19 stsp git_commit $testroot/repo -m "added numbers file"
295 3cbbd752 2019-02-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
297 3cbbd752 2019-02-19 stsp if [ "$ret" != "0" ]; then
298 3cbbd752 2019-02-19 stsp test_done "$testroot" "$ret"
302 3cbbd752 2019-02-19 stsp sed -i 's/2/22/' $testroot/repo/numbers
303 3cbbd752 2019-02-19 stsp git_commit $testroot/repo -m "modified line 2"
306 3cbbd752 2019-02-19 stsp # modify line 2 again; no local changes are left after merge
307 3cbbd752 2019-02-19 stsp sed -i 's/2/22/' $testroot/wt/numbers
309 3cbbd752 2019-02-19 stsp echo "G numbers" > $testroot/stdout.expected
310 3cbbd752 2019-02-19 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
311 3cbbd752 2019-02-19 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
312 3cbbd752 2019-02-19 stsp echo >> $testroot/stdout.expected
314 3cbbd752 2019-02-19 stsp (cd $testroot/wt && got update > $testroot/stdout)
316 3cbbd752 2019-02-19 stsp cmp $testroot/stdout.expected $testroot/stdout
318 3cbbd752 2019-02-19 stsp if [ "$ret" != "0" ]; then
319 3cbbd752 2019-02-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
320 3cbbd752 2019-02-19 stsp test_done "$testroot" "$ret"
324 2c201a36 2019-02-10 stsp echo -n > $testroot/stdout.expected
326 2c201a36 2019-02-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
328 2c201a36 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
330 2c201a36 2019-02-10 stsp if [ "$ret" != "0" ]; then
331 2c201a36 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
333 2c201a36 2019-02-10 stsp test_done "$testroot" "$ret"
336 35dc4510 2019-02-04 stsp run_test test_status_basic
337 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods
338 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods2
339 0dbc2271 2019-02-05 stsp run_test test_status_obstructed
340 02c07007 2019-02-10 stsp run_test test_status_shows_local_mods_after_update
341 18831e78 2019-02-10 stsp run_test test_status_unversioned_subdirs
342 2c201a36 2019-02-10 stsp run_test test_status_ignores_symlink
343 3cbbd752 2019-02-19 stsp run_test test_status_shows_no_mods_after_complete_merge