3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 function test_status_basic {
20 local testroot=`test_init status_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
29 echo "modified alpha" > $testroot/wt/alpha
30 echo "unversioned file" > $testroot/wt/foo
31 rm $testroot/wt/epsilon/zeta
32 touch $testroot/wt/beta
34 echo 'M alpha' > $testroot/stdout.expected
35 echo '! epsilon/zeta' >> $testroot/stdout.expected
36 echo '? foo' >> $testroot/stdout.expected
38 (cd $testroot/wt && got status > $testroot/stdout)
40 cmp $testroot/stdout.expected $testroot/stdout
42 if [ "$ret" != "0" ]; then
43 diff -u $testroot/stdout.expected $testroot/stdout
45 test_done "$testroot" "$ret"
48 function test_status_subdir_no_mods {
49 local testroot=`test_init status_subdir_no_mods 1`
51 mkdir $testroot/repo/Basic/
52 mkdir $testroot/repo/Basic/Targets/
53 touch $testroot/repo/Basic/Targets/AArch64.cpp
54 touch $testroot/repo/Basic/Targets.cpp
55 touch $testroot/repo/Basic/Targets.h
56 (cd $testroot/repo && git add .)
57 git_commit $testroot/repo -m "add subdir with files"
59 got checkout $testroot/repo $testroot/wt > /dev/null
61 if [ "$ret" != "0" ]; then
62 test_done "$testroot" "$ret"
66 touch $testroot/stdout.expected
68 # This used to erroneously print:
72 (cd $testroot/wt && got status > $testroot/stdout)
74 cmp $testroot/stdout.expected $testroot/stdout
76 if [ "$ret" != "0" ]; then
77 diff -u $testroot/stdout.expected $testroot/stdout
79 test_done "$testroot" "$ret"
82 function test_status_subdir_no_mods2 {
83 local testroot=`test_init status_subdir_no_mods2 1`
85 mkdir $testroot/repo/AST
86 touch $testroot/repo/AST/APValue.cpp
87 mkdir $testroot/repo/ASTMatchers
88 touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
89 mkdir $testroot/repo/Frontend
90 touch $testroot/repo/Frontend/ASTConsumers.cpp
91 mkdir $testroot/repo/Frontend/Rewrite
92 touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
93 mkdir $testroot/repo/FrontendTool
94 touch $testroot/repo/FrontendTool/CMakeLists.txt
95 touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
96 (cd $testroot/repo && git add .)
97 git_commit $testroot/repo -m "add subdir with files"
99 got checkout $testroot/repo $testroot/wt > /dev/null
101 if [ "$ret" != "0" ]; then
102 test_done "$testroot" "$ret"
106 touch $testroot/stdout.expected
108 # This used to erroneously print:
112 # ! Frontend/ASTConsumers.cpp
113 # ! Frontend/Rewrite/CMakeLists.txt
114 # ? Frontend/ASTConsumers.cpp
115 # ? Frontend/Rewrite/CMakeLists.txt
116 (cd $testroot/wt && got status > $testroot/stdout)
118 cmp $testroot/stdout.expected $testroot/stdout
120 if [ "$ret" != "0" ]; then
121 diff -u $testroot/stdout.expected $testroot/stdout
123 test_done "$testroot" "$ret"
126 function test_status_obstructed {
127 local testroot=`test_init status_obstructed`
129 got checkout $testroot/repo $testroot/wt > /dev/null
131 if [ "$ret" != "0" ]; then
132 test_done "$testroot" "$ret"
136 rm $testroot/wt/epsilon/zeta
137 mkdir $testroot/wt/epsilon/zeta
139 echo '~ epsilon/zeta' > $testroot/stdout.expected
141 (cd $testroot/wt && got status > $testroot/stdout)
143 cmp $testroot/stdout.expected $testroot/stdout
145 if [ "$?" != "0" ]; then
146 diff -u $testroot/stdout.expected $testroot/stdout
148 test_done "$testroot" "$ret"
151 function test_status_shows_local_mods_after_update {
152 local testroot=`test_init status_shows_local_mods_after_update 1`
154 echo "1" > $testroot/repo/numbers
155 echo "2" >> $testroot/repo/numbers
156 echo "3" >> $testroot/repo/numbers
157 echo "4" >> $testroot/repo/numbers
158 echo "5" >> $testroot/repo/numbers
159 echo "6" >> $testroot/repo/numbers
160 echo "7" >> $testroot/repo/numbers
161 echo "8" >> $testroot/repo/numbers
162 (cd $testroot/repo && git add numbers)
163 git_commit $testroot/repo -m "added numbers file"
165 got checkout $testroot/repo $testroot/wt > /dev/null
167 if [ "$ret" != "0" ]; then
168 test_done "$testroot" "$ret"
172 sed -i 's/2/22/' $testroot/repo/numbers
173 git_commit $testroot/repo -m "modified line 2"
175 # modify line 7; both changes should merge cleanly
176 sed -i 's/7/77/' $testroot/wt/numbers
178 echo "G numbers" > $testroot/stdout.expected
179 echo -n "Updated to commit " >> $testroot/stdout.expected
180 git_show_head $testroot/repo >> $testroot/stdout.expected
181 echo >> $testroot/stdout.expected
183 (cd $testroot/wt && got update > $testroot/stdout)
185 cmp $testroot/stdout.expected $testroot/stdout
187 if [ "$ret" != "0" ]; then
188 diff -u $testroot/stdout.expected $testroot/stdout
189 test_done "$testroot" "$ret"
193 echo 'M numbers' > $testroot/stdout.expected
195 (cd $testroot/wt && got status > $testroot/stdout)
197 cmp $testroot/stdout.expected $testroot/stdout
199 if [ "$ret" != "0" ]; then
200 diff -u $testroot/stdout.expected $testroot/stdout
202 test_done "$testroot" "$ret"
205 function test_status_unversioned_subdirs {
206 local testroot=`test_init status_unversioned_subdirs 1`
208 mkdir $testroot/repo/cdfs/
209 touch $testroot/repo/cdfs/Makefile
210 mkdir $testroot/repo/common/
211 touch $testroot/repo/common/Makefile
212 mkdir $testroot/repo/iso/
213 touch $testroot/repo/iso/Makefile
214 mkdir $testroot/repo/ramdisk/
215 touch $testroot/repo/ramdisk/Makefile
216 touch $testroot/repo/ramdisk/list.local
217 mkdir $testroot/repo/ramdisk_cd/
218 touch $testroot/repo/ramdisk_cd/Makefile
219 touch $testroot/repo/ramdisk_cd/list.local
220 (cd $testroot/repo && git add .)
221 git_commit $testroot/repo -m "first commit"
223 got checkout $testroot/repo $testroot/wt > /dev/null
225 if [ "$ret" != "0" ]; then
226 test_done "$testroot" "$ret"
230 mkdir $testroot/wt/cdfs/obj
231 mkdir $testroot/wt/ramdisk/obj
232 mkdir $testroot/wt/ramdisk_cd/obj
233 mkdir $testroot/wt/iso/obj
235 echo -n > $testroot/stdout.expected
237 # This used to erroneously print:
239 # ! ramdisk_cd/Makefile
240 # ! ramdisk_cd/list.local
241 # ? ramdisk_cd/Makefile
242 # ? ramdisk_cd/list.local
243 (cd $testroot/wt && got status > $testroot/stdout)
245 cmp $testroot/stdout.expected $testroot/stdout
247 if [ "$ret" != "0" ]; then
248 diff -u $testroot/stdout.expected $testroot/stdout
250 test_done "$testroot" "$ret"
253 # 'got status' ignores symlinks at present; this might change eventually
254 function test_status_ignores_symlink {
255 local testroot=`test_init status_ignores_symlink 1`
257 mkdir $testroot/repo/ramdisk/
258 touch $testroot/repo/ramdisk/Makefile
259 (cd $testroot/repo && git add .)
260 git_commit $testroot/repo -m "first commit"
262 got checkout $testroot/repo $testroot/wt > /dev/null
264 if [ "$ret" != "0" ]; then
265 test_done "$testroot" "$ret"
269 ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj
271 echo -n > $testroot/stdout.expected
273 (cd $testroot/wt && got status > $testroot/stdout)
275 cmp $testroot/stdout.expected $testroot/stdout
277 if [ "$ret" != "0" ]; then
278 diff -u $testroot/stdout.expected $testroot/stdout
280 test_done "$testroot" "$ret"
283 run_test test_status_basic
284 run_test test_status_subdir_no_mods
285 run_test test_status_subdir_no_mods2
286 run_test test_status_obstructed
287 run_test test_status_shows_local_mods_after_update
288 run_test test_status_unversioned_subdirs
289 run_test test_status_ignores_symlink