Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
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.
8 #
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.
17 . ./common.sh
19 function test_status_basic {
20 local testroot=`test_init status_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 if [ "$?" != "0" ]; then
24 test_done "$testroot" "$?"
25 return 1
26 fi
28 echo "modified alpha" > $testroot/wt/alpha
29 echo "unversioned file" > $testroot/wt/foo
30 rm $testroot/wt/epsilon/zeta
31 touch $testroot/wt/beta
33 echo 'M alpha' > $testroot/stdout.expected
34 echo '! epsilon/zeta' >> $testroot/stdout.expected
35 echo '? foo' >> $testroot/stdout.expected
37 (cd $testroot/wt && got status > $testroot/stdout)
39 cmp $testroot/stdout.expected $testroot/stdout
40 if [ "$?" != "0" ]; then
41 diff -u $testroot/stdout.expected $testroot/stdout
42 test_done "$testroot" "$?"
43 return 1
44 fi
46 test_done "$testroot" "0"
47 }
49 function test_status_subdir_no_mods {
50 local testroot=`test_init status_subdir_no_mods 1`
52 mkdir $testroot/repo/Basic/
53 mkdir $testroot/repo/Basic/Targets/
54 touch $testroot/repo/Basic/Targets/AArch64.cpp
55 touch $testroot/repo/Basic/Targets.cpp
56 touch $testroot/repo/Basic/Targets.h
57 (cd $testroot/repo && git add .)
58 git_commit $testroot/repo -m "add subdir with files"
60 got checkout $testroot/repo $testroot/wt > /dev/null
61 if [ "$?" != "0" ]; then
62 test_done "$testroot" "$?"
63 return 1
64 fi
66 touch $testroot/stdout.expected
68 # This used to erroneously print:
69 #
70 # ! Basic/Targets.cpp
71 # ? Basic/Targets.cpp
72 (cd $testroot/wt && got status > $testroot/stdout)
74 cmp $testroot/stdout.expected $testroot/stdout
75 if [ "$?" != "0" ]; then
76 diff -u $testroot/stdout.expected $testroot/stdout
77 test_done "$testroot" "$?"
78 return 1
79 fi
81 test_done "$testroot" "0"
82 }
84 function test_status_subdir_no_mods2 {
85 local testroot=`test_init status_subdir_no_mods2 1`
87 mkdir $testroot/repo/AST
88 touch $testroot/repo/AST/APValue.cpp
89 mkdir $testroot/repo/ASTMatchers
90 touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
91 mkdir $testroot/repo/Frontend
92 touch $testroot/repo/Frontend/ASTConsumers.cpp
93 mkdir $testroot/repo/Frontend/Rewrite
94 touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
95 mkdir $testroot/repo/FrontendTool
96 touch $testroot/repo/FrontendTool/CMakeLists.txt
97 touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
98 (cd $testroot/repo && git add .)
99 git_commit $testroot/repo -m "add subdir with files"
101 got checkout $testroot/repo $testroot/wt > /dev/null
102 if [ "$?" != "0" ]; then
103 test_done "$testroot" "$?"
104 return 1
105 fi
107 touch $testroot/stdout.expected
109 # This used to erroneously print:
111 # ! AST/APValue.cpp
112 # ? AST/APValue.cpp
113 # ! Frontend/ASTConsumers.cpp
114 # ! Frontend/Rewrite/CMakeLists.txt
115 # ? Frontend/ASTConsumers.cpp
116 # ? Frontend/Rewrite/CMakeLists.txt
117 (cd $testroot/wt && got status > $testroot/stdout)
119 cmp $testroot/stdout.expected $testroot/stdout
120 if [ "$?" != "0" ]; then
121 diff -u $testroot/stdout.expected $testroot/stdout
122 test_done "$testroot" "$?"
123 return 1
124 fi
126 test_done "$testroot" "0"
129 function test_status_obstructed {
130 local testroot=`test_init status_obstructed`
132 got checkout $testroot/repo $testroot/wt > /dev/null
133 if [ "$?" != "0" ]; then
134 test_done "$testroot" "$?"
135 return 1
136 fi
138 rm $testroot/wt/epsilon/zeta
139 mkdir $testroot/wt/epsilon/zeta
141 echo '~ epsilon/zeta' > $testroot/stdout.expected
143 (cd $testroot/wt && got status > $testroot/stdout)
145 cmp $testroot/stdout.expected $testroot/stdout
146 if [ "$?" != "0" ]; then
147 diff -u $testroot/stdout.expected $testroot/stdout
148 test_done "$testroot" "$?"
149 return 1
150 fi
152 test_done "$testroot" "0"
155 run_test test_status_basic
156 run_test test_status_subdir_no_mods
157 run_test test_status_subdir_no_mods2
158 run_test test_status_obstructed