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 35dc4510 2019-02-04 stsp
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
35 35dc4510 2019-02-04 stsp
36 35dc4510 2019-02-04 stsp (cd $testroot/wt && got status > $testroot/stdout)
37 35dc4510 2019-02-04 stsp
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" "$?"
42 35dc4510 2019-02-04 stsp return 1
43 35dc4510 2019-02-04 stsp fi
44 35dc4510 2019-02-04 stsp
45 35dc4510 2019-02-04 stsp test_done "$testroot" "0"
46 35dc4510 2019-02-04 stsp }
47 35dc4510 2019-02-04 stsp
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`
50 f02ba292 2019-02-05 stsp
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"
58 f02ba292 2019-02-05 stsp
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" "$?"
62 f02ba292 2019-02-05 stsp return 1
63 f02ba292 2019-02-05 stsp fi
64 f02ba292 2019-02-05 stsp
65 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
66 f02ba292 2019-02-05 stsp
67 f02ba292 2019-02-05 stsp # This used to erroneously print:
68 f02ba292 2019-02-05 stsp #
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)
72 f02ba292 2019-02-05 stsp
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" "$?"
77 f02ba292 2019-02-05 stsp return 1
78 f02ba292 2019-02-05 stsp fi
79 f02ba292 2019-02-05 stsp
80 f02ba292 2019-02-05 stsp test_done "$testroot" "0"
81 f02ba292 2019-02-05 stsp }
82 f02ba292 2019-02-05 stsp
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`
85 f02ba292 2019-02-05 stsp
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"
99 f02ba292 2019-02-05 stsp
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" "$?"
103 f02ba292 2019-02-05 stsp return 1
104 f02ba292 2019-02-05 stsp fi
105 f02ba292 2019-02-05 stsp
106 f02ba292 2019-02-05 stsp touch $testroot/stdout.expected
107 f02ba292 2019-02-05 stsp
108 f02ba292 2019-02-05 stsp # This used to erroneously print:
109 f02ba292 2019-02-05 stsp #
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)
117 f02ba292 2019-02-05 stsp
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" "$?"
122 f02ba292 2019-02-05 stsp return 1
123 f02ba292 2019-02-05 stsp fi
124 f02ba292 2019-02-05 stsp
125 f02ba292 2019-02-05 stsp test_done "$testroot" "0"
126 f02ba292 2019-02-05 stsp }
127 f02ba292 2019-02-05 stsp
128 0dbc2271 2019-02-05 stsp function test_status_obstructed {
129 0dbc2271 2019-02-05 stsp local testroot=`test_init status_obstructed`
130 0dbc2271 2019-02-05 stsp
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" "$?"
134 0dbc2271 2019-02-05 stsp return 1
135 0dbc2271 2019-02-05 stsp fi
136 0dbc2271 2019-02-05 stsp
137 0dbc2271 2019-02-05 stsp rm $testroot/wt/epsilon/zeta
138 0dbc2271 2019-02-05 stsp mkdir $testroot/wt/epsilon/zeta
139 0dbc2271 2019-02-05 stsp
140 0dbc2271 2019-02-05 stsp echo '~ epsilon/zeta' > $testroot/stdout.expected
141 0dbc2271 2019-02-05 stsp
142 0dbc2271 2019-02-05 stsp (cd $testroot/wt && got status > $testroot/stdout)
143 0dbc2271 2019-02-05 stsp
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" "$?"
148 0dbc2271 2019-02-05 stsp return 1
149 0dbc2271 2019-02-05 stsp fi
150 0dbc2271 2019-02-05 stsp
151 0dbc2271 2019-02-05 stsp test_done "$testroot" "0"
152 0dbc2271 2019-02-05 stsp }
153 0dbc2271 2019-02-05 stsp
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