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
23 35dc4510 2019-02-04 stsp if [ "$?" != "0" ]; then
24 35dc4510 2019-02-04 stsp test_done "$testroot" "$?"
28 35dc4510 2019-02-04 stsp echo "modified alpha" > $testroot/wt/alpha
29 35dc4510 2019-02-04 stsp echo "unversioned file" > $testroot/wt/foo
30 35dc4510 2019-02-04 stsp rm $testroot/wt/epsilon/zeta
32 35dc4510 2019-02-04 stsp echo 'M alpha' > $testroot/stdout.expected
33 35dc4510 2019-02-04 stsp echo '! epsilon/zeta' >> $testroot/stdout.expected
34 35dc4510 2019-02-04 stsp echo '? foo' >> $testroot/stdout.expected
36 35dc4510 2019-02-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
38 35dc4510 2019-02-04 stsp cmp $testroot/stdout.expected $testroot/stdout
39 35dc4510 2019-02-04 stsp if [ "$?" != "0" ]; then
40 35dc4510 2019-02-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
41 35dc4510 2019-02-04 stsp test_done "$testroot" "$?"
45 35dc4510 2019-02-04 stsp test_done "$testroot" "0"
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
60 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
61 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
65 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
67 f02ba292 2019-02-05 stsp # This used to erroneously print:
69 f02ba292 2019-02-05 stsp # ! Basic/Targets.cpp
70 f02ba292 2019-02-05 stsp # ? Basic/Targets.cpp
71 f02ba292 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
73 f02ba292 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
74 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
75 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
76 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
80 f02ba292 2019-02-05 stsp test_done "$testroot" "0"
83 f02ba292 2019-02-05 stsp function test_status_subdir_no_mods2 {
84 f02ba292 2019-02-05 stsp local testroot=`test_init status_subdir_no_mods2 1`
86 f02ba292 2019-02-05 stsp mkdir $testroot/repo/AST
87 f02ba292 2019-02-05 stsp touch $testroot/repo/AST/APValue.cpp
88 f02ba292 2019-02-05 stsp mkdir $testroot/repo/ASTMatchers
89 f02ba292 2019-02-05 stsp touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
90 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend
91 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/ASTConsumers.cpp
92 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend/Rewrite
93 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
94 f02ba292 2019-02-05 stsp mkdir $testroot/repo/FrontendTool
95 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/CMakeLists.txt
96 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
97 f02ba292 2019-02-05 stsp (cd $testroot/repo && git add .)
98 f02ba292 2019-02-05 stsp git_commit $testroot/repo -m "add subdir with files"
100 f02ba292 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
101 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
102 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
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
119 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
120 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
121 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
125 f02ba292 2019-02-05 stsp test_done "$testroot" "0"
128 0dbc2271 2019-02-05 stsp function test_status_obstructed {
129 0dbc2271 2019-02-05 stsp local testroot=`test_init status_obstructed`
131 0dbc2271 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
132 0dbc2271 2019-02-05 stsp if [ "$?" != "0" ]; then
133 0dbc2271 2019-02-05 stsp test_done "$testroot" "$?"
137 0dbc2271 2019-02-05 stsp rm $testroot/wt/epsilon/zeta
138 0dbc2271 2019-02-05 stsp mkdir $testroot/wt/epsilon/zeta
140 0dbc2271 2019-02-05 stsp echo '~ epsilon/zeta' > $testroot/stdout.expected
142 0dbc2271 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
144 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
147 0dbc2271 2019-02-05 stsp test_done "$testroot" "$?"
151 0dbc2271 2019-02-05 stsp test_done "$testroot" "0"
154 35dc4510 2019-02-04 stsp run_test test_status_basic
155 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods
156 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods2
157 0dbc2271 2019-02-05 stsp run_test test_status_obstructed