Blame


1 35dc4510 2019-02-04 stsp #!/bin/sh
2 35dc4510 2019-02-04 stsp #
3 35dc4510 2019-02-04 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 35dc4510 2019-02-04 stsp #
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.
8 35dc4510 2019-02-04 stsp #
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.
16 35dc4510 2019-02-04 stsp
17 35dc4510 2019-02-04 stsp . ./common.sh
18 35dc4510 2019-02-04 stsp
19 35dc4510 2019-02-04 stsp function test_status_basic {
20 35dc4510 2019-02-04 stsp local testroot=`test_init status_basic`
21 35dc4510 2019-02-04 stsp
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" "$?"
25 35dc4510 2019-02-04 stsp return 1
26 35dc4510 2019-02-04 stsp fi
27 35dc4510 2019-02-04 stsp
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
31 14e5d4dc 2019-02-05 stsp touch $testroot/wt/beta
32 35dc4510 2019-02-04 stsp
33 35dc4510 2019-02-04 stsp echo 'M alpha' > $testroot/stdout.expected
34 35dc4510 2019-02-04 stsp echo '! epsilon/zeta' >> $testroot/stdout.expected
35 35dc4510 2019-02-04 stsp echo '? foo' >> $testroot/stdout.expected
36 35dc4510 2019-02-04 stsp
37 35dc4510 2019-02-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
38 35dc4510 2019-02-04 stsp
39 35dc4510 2019-02-04 stsp cmp $testroot/stdout.expected $testroot/stdout
40 35dc4510 2019-02-04 stsp if [ "$?" != "0" ]; then
41 35dc4510 2019-02-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
42 35dc4510 2019-02-04 stsp test_done "$testroot" "$?"
43 35dc4510 2019-02-04 stsp return 1
44 35dc4510 2019-02-04 stsp fi
45 35dc4510 2019-02-04 stsp
46 35dc4510 2019-02-04 stsp test_done "$testroot" "0"
47 35dc4510 2019-02-04 stsp }
48 35dc4510 2019-02-04 stsp
49 f02ba292 2019-02-05 stsp function test_status_subdir_no_mods {
50 f02ba292 2019-02-05 stsp local testroot=`test_init status_subdir_no_mods 1`
51 f02ba292 2019-02-05 stsp
52 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Basic/
53 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Basic/Targets/
54 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets/AArch64.cpp
55 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets.cpp
56 f02ba292 2019-02-05 stsp touch $testroot/repo/Basic/Targets.h
57 f02ba292 2019-02-05 stsp (cd $testroot/repo && git add .)
58 f02ba292 2019-02-05 stsp git_commit $testroot/repo -m "add subdir with files"
59 f02ba292 2019-02-05 stsp
60 f02ba292 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
61 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
62 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
63 f02ba292 2019-02-05 stsp return 1
64 f02ba292 2019-02-05 stsp fi
65 f02ba292 2019-02-05 stsp
66 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
67 f02ba292 2019-02-05 stsp
68 f02ba292 2019-02-05 stsp # This used to erroneously print:
69 f02ba292 2019-02-05 stsp #
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)
73 f02ba292 2019-02-05 stsp
74 f02ba292 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
75 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
76 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
77 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
78 f02ba292 2019-02-05 stsp return 1
79 f02ba292 2019-02-05 stsp fi
80 f02ba292 2019-02-05 stsp
81 f02ba292 2019-02-05 stsp test_done "$testroot" "0"
82 f02ba292 2019-02-05 stsp }
83 f02ba292 2019-02-05 stsp
84 f02ba292 2019-02-05 stsp function test_status_subdir_no_mods2 {
85 f02ba292 2019-02-05 stsp local testroot=`test_init status_subdir_no_mods2 1`
86 f02ba292 2019-02-05 stsp
87 f02ba292 2019-02-05 stsp mkdir $testroot/repo/AST
88 f02ba292 2019-02-05 stsp touch $testroot/repo/AST/APValue.cpp
89 f02ba292 2019-02-05 stsp mkdir $testroot/repo/ASTMatchers
90 f02ba292 2019-02-05 stsp touch $testroot/repo/ASTMatchers/ASTMatchFinder.cpp
91 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend
92 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/ASTConsumers.cpp
93 f02ba292 2019-02-05 stsp mkdir $testroot/repo/Frontend/Rewrite
94 f02ba292 2019-02-05 stsp touch $testroot/repo/Frontend/Rewrite/CMakeLists.txt
95 f02ba292 2019-02-05 stsp mkdir $testroot/repo/FrontendTool
96 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/CMakeLists.txt
97 f02ba292 2019-02-05 stsp touch $testroot/repo/FrontendTool/ExecuteCompilerInvocation.cpp
98 f02ba292 2019-02-05 stsp (cd $testroot/repo && git add .)
99 f02ba292 2019-02-05 stsp git_commit $testroot/repo -m "add subdir with files"
100 f02ba292 2019-02-05 stsp
101 f02ba292 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
102 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
103 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
104 f02ba292 2019-02-05 stsp return 1
105 f02ba292 2019-02-05 stsp fi
106 f02ba292 2019-02-05 stsp
107 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
108 f02ba292 2019-02-05 stsp
109 f02ba292 2019-02-05 stsp # This used to erroneously print:
110 f02ba292 2019-02-05 stsp #
111 f02ba292 2019-02-05 stsp # ! AST/APValue.cpp
112 f02ba292 2019-02-05 stsp # ? AST/APValue.cpp
113 f02ba292 2019-02-05 stsp # ! Frontend/ASTConsumers.cpp
114 f02ba292 2019-02-05 stsp # ! Frontend/Rewrite/CMakeLists.txt
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 (cd $testroot/wt && got status > $testroot/stdout)
118 f02ba292 2019-02-05 stsp
119 f02ba292 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
120 f02ba292 2019-02-05 stsp if [ "$?" != "0" ]; then
121 f02ba292 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
122 f02ba292 2019-02-05 stsp test_done "$testroot" "$?"
123 f02ba292 2019-02-05 stsp return 1
124 f02ba292 2019-02-05 stsp fi
125 f02ba292 2019-02-05 stsp
126 f02ba292 2019-02-05 stsp test_done "$testroot" "0"
127 f02ba292 2019-02-05 stsp }
128 f02ba292 2019-02-05 stsp
129 0dbc2271 2019-02-05 stsp function test_status_obstructed {
130 0dbc2271 2019-02-05 stsp local testroot=`test_init status_obstructed`
131 0dbc2271 2019-02-05 stsp
132 0dbc2271 2019-02-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
133 0dbc2271 2019-02-05 stsp if [ "$?" != "0" ]; then
134 0dbc2271 2019-02-05 stsp test_done "$testroot" "$?"
135 0dbc2271 2019-02-05 stsp return 1
136 0dbc2271 2019-02-05 stsp fi
137 0dbc2271 2019-02-05 stsp
138 0dbc2271 2019-02-05 stsp rm $testroot/wt/epsilon/zeta
139 0dbc2271 2019-02-05 stsp mkdir $testroot/wt/epsilon/zeta
140 0dbc2271 2019-02-05 stsp
141 0dbc2271 2019-02-05 stsp echo '~ epsilon/zeta' > $testroot/stdout.expected
142 0dbc2271 2019-02-05 stsp
143 0dbc2271 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
144 0dbc2271 2019-02-05 stsp
145 0dbc2271 2019-02-05 stsp cmp $testroot/stdout.expected $testroot/stdout
146 0dbc2271 2019-02-05 stsp if [ "$?" != "0" ]; then
147 0dbc2271 2019-02-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
148 0dbc2271 2019-02-05 stsp test_done "$testroot" "$?"
149 0dbc2271 2019-02-05 stsp return 1
150 0dbc2271 2019-02-05 stsp fi
151 0dbc2271 2019-02-05 stsp
152 0dbc2271 2019-02-05 stsp test_done "$testroot" "0"
153 0dbc2271 2019-02-05 stsp }
154 0dbc2271 2019-02-05 stsp
155 35dc4510 2019-02-04 stsp run_test test_status_basic
156 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods
157 f02ba292 2019-02-05 stsp run_test test_status_subdir_no_mods2
158 0dbc2271 2019-02-05 stsp run_test test_status_obstructed