Blob


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