3 c4296144 2019-05-09 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 c4296144 2019-05-09 stsp # Permission to use, copy, modify, and distribute this software for any
6 c4296144 2019-05-09 stsp # purpose with or without fee is hereby granted, provided that the above
7 c4296144 2019-05-09 stsp # copyright notice and this permission notice appear in all copies.
9 c4296144 2019-05-09 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c4296144 2019-05-09 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c4296144 2019-05-09 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c4296144 2019-05-09 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c4296144 2019-05-09 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c4296144 2019-05-09 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c4296144 2019-05-09 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 c4296144 2019-05-09 stsp . ./common.sh
19 c4296144 2019-05-09 stsp function test_commit_basic {
20 c4296144 2019-05-09 stsp local testroot=`test_init commit_basic`
22 c4296144 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
25 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
29 c4296144 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
30 c4296144 2019-05-09 stsp (cd $testroot/wt && got rm beta >/dev/null)
31 c4296144 2019-05-09 stsp echo "new file" > $testroot/wt/new
32 c4296144 2019-05-09 stsp (cd $testroot/wt && got add new >/dev/null)
34 83a7ae6d 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
36 c4296144 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
37 afa376bf 2019-05-09 stsp echo "A new" > $testroot/stdout.expected
38 afa376bf 2019-05-09 stsp echo "M alpha" >> $testroot/stdout.expected
39 afa376bf 2019-05-09 stsp echo "D beta" >> $testroot/stdout.expected
40 c4296144 2019-05-09 stsp echo "created commit $head_rev" >> $testroot/stdout.expected
42 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
44 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
45 c4296144 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
47 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
50 baa7dcfa 2019-05-09 stsp function test_commit_new_subdir {
51 baa7dcfa 2019-05-09 stsp local testroot=`test_init commit_new_subdir`
53 baa7dcfa 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
55 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
56 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
60 baa7dcfa 2019-05-09 stsp mkdir -p $testroot/wt/d
61 baa7dcfa 2019-05-09 stsp echo "new file" > $testroot/wt/d/new
62 baa7dcfa 2019-05-09 stsp echo "another new file" > $testroot/wt/d/new2
63 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new >/dev/null)
64 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new2 >/dev/null)
66 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && \
67 baa7dcfa 2019-05-09 stsp got commit -m 'test commit_new_subdir' > $testroot/stdout)
69 baa7dcfa 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
70 baa7dcfa 2019-05-09 stsp echo "A d/new" > $testroot/stdout.expected
71 baa7dcfa 2019-05-09 stsp echo "A d/new2" >> $testroot/stdout.expected
72 baa7dcfa 2019-05-09 stsp echo "created commit $head_rev" >> $testroot/stdout.expected
74 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
77 baa7dcfa 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
82 bc70eb79 2019-05-09 stsp function test_commit_subdir {
83 bc70eb79 2019-05-09 stsp local testroot=`test_init commit_subdir`
85 bc70eb79 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
87 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
88 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
92 bc70eb79 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
93 bc70eb79 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
95 bc70eb79 2019-05-09 stsp (cd $testroot/wt && \
96 bc70eb79 2019-05-09 stsp got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
98 bc70eb79 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
99 bc70eb79 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
100 bc70eb79 2019-05-09 stsp echo "created commit $head_rev" >> $testroot/stdout.expected
102 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
104 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
105 bc70eb79 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
107 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
110 5bbcb68b 2019-05-09 stsp function test_commit_single_file {
111 5bbcb68b 2019-05-09 stsp local testroot=`test_init commit_single_file`
113 5bbcb68b 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
115 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
116 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
120 5bbcb68b 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
121 5bbcb68b 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
123 5bbcb68b 2019-05-09 stsp (cd $testroot/wt && got commit -m 'test commit_subdir' epsilon/zeta \
124 5bbcb68b 2019-05-09 stsp > $testroot/stdout)
126 5bbcb68b 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
127 5bbcb68b 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
128 5bbcb68b 2019-05-09 stsp echo "created commit $head_rev" >> $testroot/stdout.expected
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
133 5bbcb68b 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
138 819f385b 2019-05-10 stsp function test_commit_out_of_date {
139 819f385b 2019-05-10 stsp local testroot=`test_init commit_out_of_date`
141 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
144 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
148 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/repo/alpha
149 819f385b 2019-05-10 stsp git_commit $testroot/repo -m "modified alpha"
151 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/wt/alpha
153 819f385b 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_out_of_date' \
154 819f385b 2019-05-10 stsp > $testroot/stdout 2> $testroot/stderr)
156 819f385b 2019-05-10 stsp local head_rev=`git_show_head $testroot/repo`
157 819f385b 2019-05-10 stsp echo -n > $testroot/stdout.expected
158 819f385b 2019-05-10 stsp echo "got: work tree must be updated before these" \
159 819f385b 2019-05-10 stsp "changes can be committed" > $testroot/stderr.expected
161 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
163 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
164 819f385b 2019-05-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
165 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
169 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
171 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
172 819f385b 2019-05-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
174 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
177 8ba6ba2d 2019-05-14 stsp function test_commit_added_subdirs {
178 8ba6ba2d 2019-05-14 stsp local testroot=`test_init commit_added_subdirs`
180 8ba6ba2d 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
182 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
183 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
187 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d
188 8ba6ba2d 2019-05-14 stsp echo "new file" > $testroot/wt/d/new
189 8ba6ba2d 2019-05-14 stsp echo "new file 2" > $testroot/wt/d/new2
190 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f
191 8ba6ba2d 2019-05-14 stsp echo "new file 3" > $testroot/wt/d/f/new3
192 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f/g
193 8ba6ba2d 2019-05-14 stsp echo "new file 4" > $testroot/wt/d/f/g/new4
195 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got add $testroot/wt/*/new* \
196 8ba6ba2d 2019-05-14 stsp $testroot/wt/*/*/new* $testroot/wt/*/*/*/new* > /dev/null)
198 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got commit -m 'test commit_added_subdirs' \
199 8ba6ba2d 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
201 8ba6ba2d 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
202 a3df2849 2019-05-20 stsp echo "A d/f/g/new4" > $testroot/stdout.expected
203 a3df2849 2019-05-20 stsp echo "A d/f/new3" >> $testroot/stdout.expected
204 8ba6ba2d 2019-05-14 stsp echo "A d/new" >> $testroot/stdout.expected
205 8ba6ba2d 2019-05-14 stsp echo "A d/new2" >> $testroot/stdout.expected
206 8ba6ba2d 2019-05-14 stsp echo "created commit $head_rev" >> $testroot/stdout.expected
208 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
210 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
211 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
213 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
216 c4296144 2019-05-09 stsp run_test test_commit_basic
217 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
218 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
219 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
220 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
221 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs