Blame


1 0e673013 2019-01-02 stsp #!/bin/sh
2 0e673013 2019-01-02 stsp #
3 0e673013 2019-01-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 0e673013 2019-01-02 stsp #
5 0e673013 2019-01-02 stsp # Permission to use, copy, modify, and distribute this software for any
6 0e673013 2019-01-02 stsp # purpose with or without fee is hereby granted, provided that the above
7 0e673013 2019-01-02 stsp # copyright notice and this permission notice appear in all copies.
8 0e673013 2019-01-02 stsp #
9 0e673013 2019-01-02 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 0e673013 2019-01-02 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 0e673013 2019-01-02 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 0e673013 2019-01-02 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 0e673013 2019-01-02 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 0e673013 2019-01-02 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 0e673013 2019-01-02 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 0e673013 2019-01-02 stsp
17 0e673013 2019-01-02 stsp . ./common.sh
18 0e673013 2019-01-02 stsp
19 0e673013 2019-01-02 stsp function test_checkout_basic {
20 0e673013 2019-01-02 stsp local testroot=`test_init checkout_basic`
21 0e673013 2019-01-02 stsp
22 0e673013 2019-01-02 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
23 0e673013 2019-01-02 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
24 0e673013 2019-01-02 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
25 0e673013 2019-01-02 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
26 0e673013 2019-01-02 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
27 0e673013 2019-01-02 stsp
28 0e673013 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
29 e60e7f5b 2019-02-10 stsp ret="$?"
30 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
31 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
32 0e673013 2019-01-02 stsp return 1
33 0e673013 2019-01-02 stsp fi
34 0e673013 2019-01-02 stsp
35 0e673013 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
36 e60e7f5b 2019-02-10 stsp ret="$?"
37 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
38 0e673013 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
39 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
40 0e673013 2019-01-02 stsp return 1
41 0e673013 2019-01-02 stsp fi
42 0e673013 2019-01-02 stsp
43 0e673013 2019-01-02 stsp echo "alpha" > $testroot/content.expected
44 0e673013 2019-01-02 stsp echo "beta" >> $testroot/content.expected
45 0e673013 2019-01-02 stsp echo "zeta" >> $testroot/content.expected
46 0e673013 2019-01-02 stsp echo "delta" >> $testroot/content.expected
47 0e673013 2019-01-02 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
48 0e673013 2019-01-02 stsp $testroot/wt/gamma/delta > $testroot/content
49 0e673013 2019-01-02 stsp
50 0e673013 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
51 693719bc 2019-01-03 stsp ret="$?"
52 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
53 0e673013 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
54 0e673013 2019-01-02 stsp fi
55 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
56 0e673013 2019-01-02 stsp }
57 0e673013 2019-01-02 stsp
58 68ed9ba5 2019-02-10 stsp function test_checkout_sets_xbit {
59 68ed9ba5 2019-02-10 stsp local testroot=`test_init checkout_sets_xbit 1`
60 68ed9ba5 2019-02-10 stsp
61 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
62 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
63 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
64 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
65 68ed9ba5 2019-02-10 stsp
66 68ed9ba5 2019-02-10 stsp echo "A $testroot/wt/xfile" > $testroot/stdout.expected
67 68ed9ba5 2019-02-10 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
68 68ed9ba5 2019-02-10 stsp
69 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
70 68ed9ba5 2019-02-10 stsp ret="$?"
71 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
72 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
73 68ed9ba5 2019-02-10 stsp return 1
74 68ed9ba5 2019-02-10 stsp fi
75 68ed9ba5 2019-02-10 stsp
76 68ed9ba5 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
77 68ed9ba5 2019-02-10 stsp ret="$?"
78 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
79 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
81 68ed9ba5 2019-02-10 stsp return 1
82 68ed9ba5 2019-02-10 stsp fi
83 68ed9ba5 2019-02-10 stsp
84 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
85 68ed9ba5 2019-02-10 stsp ret="$?"
86 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
87 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
88 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
89 68ed9ba5 2019-02-10 stsp fi
90 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
91 68ed9ba5 2019-02-10 stsp }
92 68ed9ba5 2019-02-10 stsp
93 0e673013 2019-01-02 stsp run_test test_checkout_basic
94 68ed9ba5 2019-02-10 stsp run_test test_checkout_sets_xbit