3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
19 function test_add_basic {
20 local testroot=`test_init add_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
29 echo "new file" > $testroot/wt/foo
31 echo 'A foo' > $testroot/stdout.expected
32 (cd $testroot/wt && got add foo > $testroot/stdout)
34 cmp -s $testroot/stdout.expected $testroot/stdout
36 if [ "$ret" != "0" ]; then
37 diff -u $testroot/stdout.expected $testroot/stdout
39 test_done "$testroot" "$ret"
42 function test_double_add {
43 local testroot=`test_init double_add`
45 got checkout $testroot/repo $testroot/wt > /dev/null
47 if [ "$ret" != "0" ]; then
48 test_done "$testroot" "$ret"
52 echo "new file" > $testroot/wt/foo
53 (cd $testroot/wt && got add foo > /dev/null)
55 (cd $testroot/wt && got add foo)
57 if [ "$ret" != "0" ]; then
58 echo "got add failed unexpectedly" >&2
59 test_done "$testroot" 1
63 test_done "$testroot" "$ret"
66 function test_add_multiple {
67 local testroot=`test_init multiple_add`
69 got checkout $testroot/repo $testroot/wt > /dev/null
71 if [ "$ret" != "0" ]; then
72 test_done "$testroot" "$ret"
76 echo "new file" > $testroot/wt/foo
77 echo "new file" > $testroot/wt/bar
78 echo "new file" > $testroot/wt/baz
79 (cd $testroot/wt && got add foo bar baz > $testroot/stdout)
81 if [ "$ret" != "0" ]; then
82 echo "got add failed unexpectedly" >&2
83 test_done "$testroot" 1
87 echo "A bar" > $testroot/stdout.expected
88 echo "A baz" >> $testroot/stdout.expected
89 echo "A foo" >> $testroot/stdout.expected
91 cmp -s $testroot/stdout.expected $testroot/stdout
93 if [ "$ret" != "0" ]; then
94 diff -u $testroot/stdout.expected $testroot/stdout
96 test_done "$testroot" "$ret"
99 run_test test_add_basic
100 run_test test_double_add
101 run_test test_add_multiple