Blame


1 4e0a20a4 2020-03-23 tracey #!/bin/sh
2 4e0a20a4 2020-03-23 tracey #
3 4e0a20a4 2020-03-23 tracey # Copyright (c) 2020 Tracey Emery <tracey@openbsd.org>
4 4e0a20a4 2020-03-23 tracey #
5 4e0a20a4 2020-03-23 tracey # Permission to use, copy, modify, and distribute this software for any
6 4e0a20a4 2020-03-23 tracey # purpose with or without fee is hereby granted, provided that the above
7 4e0a20a4 2020-03-23 tracey # copyright notice and this permission notice appear in all copies.
8 4e0a20a4 2020-03-23 tracey #
9 4e0a20a4 2020-03-23 tracey # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 4e0a20a4 2020-03-23 tracey # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 4e0a20a4 2020-03-23 tracey # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 4e0a20a4 2020-03-23 tracey # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 4e0a20a4 2020-03-23 tracey # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 4e0a20a4 2020-03-23 tracey # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 4e0a20a4 2020-03-23 tracey # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 4e0a20a4 2020-03-23 tracey
17 4e0a20a4 2020-03-23 tracey . ./common.sh
18 4e0a20a4 2020-03-23 tracey
19 4e0a20a4 2020-03-23 tracey function test_tree_basic {
20 4e0a20a4 2020-03-23 tracey local testroot=`test_init tree_basic`
21 4e0a20a4 2020-03-23 tracey
22 4e0a20a4 2020-03-23 tracey got checkout $testroot/repo $testroot/wt > /dev/null
23 4e0a20a4 2020-03-23 tracey
24 4e0a20a4 2020-03-23 tracey echo "new file" > $testroot/wt/foo
25 4e0a20a4 2020-03-23 tracey
26 4e0a20a4 2020-03-23 tracey (cd $testroot/wt && got add foo > /dev/null)
27 810a850e 2020-03-23 tracey (cd $testroot/wt && got commit -m "add foo" foo > /dev/null)
28 4e0a20a4 2020-03-23 tracey
29 4e0a20a4 2020-03-23 tracey echo 'alpha' > $testroot/stdout.expected
30 4e0a20a4 2020-03-23 tracey echo 'beta' >> $testroot/stdout.expected
31 4e0a20a4 2020-03-23 tracey echo 'epsilon/' >> $testroot/stdout.expected
32 4e0a20a4 2020-03-23 tracey echo 'foo' >> $testroot/stdout.expected
33 4e0a20a4 2020-03-23 tracey echo 'gamma/' >> $testroot/stdout.expected
34 4e0a20a4 2020-03-23 tracey
35 4e0a20a4 2020-03-23 tracey (cd $testroot/wt && got tree > $testroot/stdout)
36 4e0a20a4 2020-03-23 tracey
37 4e0a20a4 2020-03-23 tracey cmp -s $testroot/stdout.expected $testroot/stdout
38 4e0a20a4 2020-03-23 tracey ret="$?"
39 4e0a20a4 2020-03-23 tracey if [ "$ret" != "0" ]; then
40 4e0a20a4 2020-03-23 tracey diff -u $testroot/stdout.expected $testroot/stdout
41 4e0a20a4 2020-03-23 tracey fi
42 4e0a20a4 2020-03-23 tracey
43 4e0a20a4 2020-03-23 tracey test_done "$testroot" "$ret"
44 4e0a20a4 2020-03-23 tracey }
45 4e0a20a4 2020-03-23 tracey
46 4e0a20a4 2020-03-23 tracey function test_tree_branch {
47 4e0a20a4 2020-03-23 tracey local testroot=`test_init tree_branch`
48 4e0a20a4 2020-03-23 tracey
49 4e0a20a4 2020-03-23 tracey got checkout $testroot/repo $testroot/wt > /dev/null
50 4e0a20a4 2020-03-23 tracey ret="$?"
51 4e0a20a4 2020-03-23 tracey if [ "$ret" != "0" ]; then
52 4e0a20a4 2020-03-23 tracey test_done "$testroot" "$ret"
53 4e0a20a4 2020-03-23 tracey return 1
54 4e0a20a4 2020-03-23 tracey fi
55 4e0a20a4 2020-03-23 tracey
56 4e0a20a4 2020-03-23 tracey (cd $testroot/wt && got br foo > $testroot/stdout)
57 4e0a20a4 2020-03-23 tracey
58 4e0a20a4 2020-03-23 tracey echo "new file" > $testroot/wt/foo
59 4e0a20a4 2020-03-23 tracey
60 4e0a20a4 2020-03-23 tracey (cd $testroot/wt && got add foo > /dev/null)
61 810a850e 2020-03-23 tracey (cd $testroot/wt && got commit -m "add foo" foo > /dev/null)
62 4e0a20a4 2020-03-23 tracey
63 4e0a20a4 2020-03-23 tracey echo 'alpha' > $testroot/stdout.expected
64 4e0a20a4 2020-03-23 tracey echo 'beta' >> $testroot/stdout.expected
65 4e0a20a4 2020-03-23 tracey echo 'epsilon/' >> $testroot/stdout.expected
66 4e0a20a4 2020-03-23 tracey echo 'foo' >> $testroot/stdout.expected
67 4e0a20a4 2020-03-23 tracey echo 'gamma/' >> $testroot/stdout.expected
68 4e0a20a4 2020-03-23 tracey
69 4e0a20a4 2020-03-23 tracey (cd $testroot/wt && got tree > $testroot/stdout)
70 4e0a20a4 2020-03-23 tracey
71 4e0a20a4 2020-03-23 tracey cmp -s $testroot/stdout.expected $testroot/stdout
72 4e0a20a4 2020-03-23 tracey ret="$?"
73 4e0a20a4 2020-03-23 tracey if [ "$ret" != "0" ]; then
74 4e0a20a4 2020-03-23 tracey diff -u $testroot/stdout.expected $testroot/stdout
75 4e0a20a4 2020-03-23 tracey fi
76 4e0a20a4 2020-03-23 tracey
77 4e0a20a4 2020-03-23 tracey test_done "$testroot" "$ret"
78 4e0a20a4 2020-03-23 tracey }
79 4e0a20a4 2020-03-23 tracey
80 4e0a20a4 2020-03-23 tracey run_test test_tree_basic
81 4e0a20a4 2020-03-23 tracey run_test test_tree_branch