Blame


1 c84d8c75 2019-01-02 stsp #!/bin/sh
2 c84d8c75 2019-01-02 stsp #
3 c84d8c75 2019-01-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c84d8c75 2019-01-02 stsp #
5 c84d8c75 2019-01-02 stsp # Permission to use, copy, modify, and distribute this software for any
6 c84d8c75 2019-01-02 stsp # purpose with or without fee is hereby granted, provided that the above
7 c84d8c75 2019-01-02 stsp # copyright notice and this permission notice appear in all copies.
8 c84d8c75 2019-01-02 stsp #
9 c84d8c75 2019-01-02 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c84d8c75 2019-01-02 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c84d8c75 2019-01-02 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c84d8c75 2019-01-02 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c84d8c75 2019-01-02 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c84d8c75 2019-01-02 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c84d8c75 2019-01-02 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 c84d8c75 2019-01-02 stsp
17 c84d8c75 2019-01-02 stsp . ./common.sh
18 c84d8c75 2019-01-02 stsp
19 c84d8c75 2019-01-02 stsp function test_update_basic {
20 0fbd721f 2019-01-02 stsp local testroot=`test_init update_basic`
21 c84d8c75 2019-01-02 stsp
22 3c90ba67 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 c84d8c75 2019-01-02 stsp if [ "$?" != "0" ]; then
24 c84d8c75 2019-01-02 stsp test_done "$testroot" "$?"
25 c84d8c75 2019-01-02 stsp return 1
26 c84d8c75 2019-01-02 stsp fi
27 c84d8c75 2019-01-02 stsp
28 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/repo/alpha
29 c84d8c75 2019-01-02 stsp git_commit $testroot/repo -m "modified alpha"
30 c84d8c75 2019-01-02 stsp
31 c84d8c75 2019-01-02 stsp echo "U alpha" > $testroot/stdout.expected
32 9c4b8182 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
33 9c4b8182 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
34 9c4b8182 2019-01-02 stsp echo >> $testroot/stdout.expected
35 c84d8c75 2019-01-02 stsp
36 c84d8c75 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
37 c84d8c75 2019-01-02 stsp
38 c84d8c75 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
39 c84d8c75 2019-01-02 stsp if [ "$?" != "0" ]; then
40 c84d8c75 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
41 c84d8c75 2019-01-02 stsp test_done "$testroot" "$?"
42 c84d8c75 2019-01-02 stsp return 1
43 c84d8c75 2019-01-02 stsp fi
44 c84d8c75 2019-01-02 stsp
45 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/content.expected
46 c84d8c75 2019-01-02 stsp echo "beta" >> $testroot/content.expected
47 c84d8c75 2019-01-02 stsp echo "zeta" >> $testroot/content.expected
48 c84d8c75 2019-01-02 stsp echo "delta" >> $testroot/content.expected
49 c84d8c75 2019-01-02 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
50 c84d8c75 2019-01-02 stsp $testroot/wt/gamma/delta > $testroot/content
51 c84d8c75 2019-01-02 stsp
52 c84d8c75 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
53 693719bc 2019-01-03 stsp ret="$?"
54 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
55 c84d8c75 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
56 c84d8c75 2019-01-02 stsp fi
57 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
58 c84d8c75 2019-01-02 stsp }
59 c84d8c75 2019-01-02 stsp
60 3b4d3732 2019-01-02 stsp function test_update_adds_file {
61 3b4d3732 2019-01-02 stsp local testroot=`test_init update_adds_file`
62 3b4d3732 2019-01-02 stsp
63 3b4d3732 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
64 3b4d3732 2019-01-02 stsp if [ "$?" != "0" ]; then
65 3b4d3732 2019-01-02 stsp test_done "$testroot" "$?"
66 3b4d3732 2019-01-02 stsp return 1
67 3b4d3732 2019-01-02 stsp fi
68 3b4d3732 2019-01-02 stsp
69 3b4d3732 2019-01-02 stsp echo "new" > $testroot/repo/gamma/new
70 3b4d3732 2019-01-02 stsp (cd $testroot/repo && git add .)
71 3b4d3732 2019-01-02 stsp git_commit $testroot/repo -m "adding a new file"
72 3b4d3732 2019-01-02 stsp
73 3b4d3732 2019-01-02 stsp echo "A gamma/new" > $testroot/stdout.expected
74 3b4d3732 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
75 3b4d3732 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
76 3b4d3732 2019-01-02 stsp echo >> $testroot/stdout.expected
77 3b4d3732 2019-01-02 stsp
78 3b4d3732 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
79 3b4d3732 2019-01-02 stsp
80 3b4d3732 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
81 3b4d3732 2019-01-02 stsp if [ "$?" != "0" ]; then
82 3b4d3732 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
83 3b4d3732 2019-01-02 stsp test_done "$testroot" "$?"
84 3b4d3732 2019-01-02 stsp return 1
85 3b4d3732 2019-01-02 stsp fi
86 3b4d3732 2019-01-02 stsp
87 3b4d3732 2019-01-02 stsp echo "alpha" >> $testroot/content.expected
88 3b4d3732 2019-01-02 stsp echo "beta" >> $testroot/content.expected
89 3b4d3732 2019-01-02 stsp echo "zeta" >> $testroot/content.expected
90 3b4d3732 2019-01-02 stsp echo "delta" >> $testroot/content.expected
91 3b4d3732 2019-01-02 stsp echo "new" >> $testroot/content.expected
92 3b4d3732 2019-01-02 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
93 3b4d3732 2019-01-02 stsp $testroot/wt/gamma/delta $testroot/wt/gamma/new > $testroot/content
94 3b4d3732 2019-01-02 stsp
95 3b4d3732 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
96 693719bc 2019-01-03 stsp ret="$?"
97 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
98 3b4d3732 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
99 3b4d3732 2019-01-02 stsp fi
100 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
101 3b4d3732 2019-01-02 stsp }
102 3b4d3732 2019-01-02 stsp
103 512f0d0e 2019-01-02 stsp function test_update_deletes_file {
104 512f0d0e 2019-01-02 stsp local testroot=`test_init update_deletes_file`
105 512f0d0e 2019-01-02 stsp
106 512f0d0e 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
107 512f0d0e 2019-01-02 stsp if [ "$?" != "0" ]; then
108 512f0d0e 2019-01-02 stsp test_done "$testroot" "$?"
109 512f0d0e 2019-01-02 stsp return 1
110 512f0d0e 2019-01-02 stsp fi
111 512f0d0e 2019-01-02 stsp
112 512f0d0e 2019-01-02 stsp (cd $testroot/repo && git_rm $testroot/repo beta)
113 512f0d0e 2019-01-02 stsp git_commit $testroot/repo -m "deleting a file"
114 512f0d0e 2019-01-02 stsp
115 512f0d0e 2019-01-02 stsp echo "D beta" > $testroot/stdout.expected
116 512f0d0e 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
117 512f0d0e 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
118 512f0d0e 2019-01-02 stsp echo >> $testroot/stdout.expected
119 512f0d0e 2019-01-02 stsp
120 512f0d0e 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
121 512f0d0e 2019-01-02 stsp
122 512f0d0e 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
123 512f0d0e 2019-01-02 stsp if [ "$?" != "0" ]; then
124 512f0d0e 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
125 512f0d0e 2019-01-02 stsp test_done "$testroot" "$?"
126 512f0d0e 2019-01-02 stsp return 1
127 512f0d0e 2019-01-02 stsp fi
128 512f0d0e 2019-01-02 stsp
129 512f0d0e 2019-01-02 stsp if [ -e $testroot/wt/beta ]; then
130 512f0d0e 2019-01-02 stsp echo "removed file beta still exists on disk" >&2
131 512f0d0e 2019-01-02 stsp return 1
132 512f0d0e 2019-01-02 stsp fi
133 512f0d0e 2019-01-02 stsp
134 512f0d0e 2019-01-02 stsp echo "alpha" >> $testroot/content.expected
135 512f0d0e 2019-01-02 stsp echo "zeta" >> $testroot/content.expected
136 512f0d0e 2019-01-02 stsp echo "delta" >> $testroot/content.expected
137 512f0d0e 2019-01-02 stsp cat $testroot/wt/alpha $testroot/wt/epsilon/zeta \
138 512f0d0e 2019-01-02 stsp $testroot/wt/gamma/delta > $testroot/content
139 512f0d0e 2019-01-02 stsp
140 512f0d0e 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
141 693719bc 2019-01-03 stsp ret="$?"
142 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
143 512f0d0e 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
144 512f0d0e 2019-01-02 stsp fi
145 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
146 512f0d0e 2019-01-02 stsp }
147 512f0d0e 2019-01-02 stsp
148 c84d8c75 2019-01-02 stsp run_test test_update_basic
149 3b4d3732 2019-01-02 stsp run_test test_update_adds_file
150 512f0d0e 2019-01-02 stsp run_test test_update_deletes_file