3 6dbf1e9e 2019-03-26 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 6dbf1e9e 2019-03-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 6dbf1e9e 2019-03-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 6dbf1e9e 2019-03-26 stsp # copyright notice and this permission notice appear in all copies.
9 6dbf1e9e 2019-03-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 6dbf1e9e 2019-03-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 6dbf1e9e 2019-03-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 6dbf1e9e 2019-03-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 6dbf1e9e 2019-03-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 6dbf1e9e 2019-03-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 6dbf1e9e 2019-03-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 6dbf1e9e 2019-03-26 stsp . ./common.sh
19 6dbf1e9e 2019-03-26 stsp function test_add_basic {
20 6dbf1e9e 2019-03-26 stsp local testroot=`test_init add_basic`
22 6dbf1e9e 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 6dbf1e9e 2019-03-26 stsp if [ "$ret" != "0" ]; then
25 6dbf1e9e 2019-03-26 stsp test_done "$testroot" "$ret"
29 6dbf1e9e 2019-03-26 stsp echo "new file" > $testroot/wt/foo
31 6dbf1e9e 2019-03-26 stsp echo 'A foo' > $testroot/stdout.expected
32 6dbf1e9e 2019-03-26 stsp (cd $testroot/wt && got add foo > $testroot/stdout)
34 6dbf1e9e 2019-03-26 stsp cmp $testroot/stdout.expected $testroot/stdout
36 6dbf1e9e 2019-03-26 stsp if [ "$ret" != "0" ]; then
37 6dbf1e9e 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
39 6dbf1e9e 2019-03-26 stsp test_done "$testroot" "$ret"
42 5c99ca9f 2019-03-27 stsp function test_double_add {
43 5c99ca9f 2019-03-27 stsp local testroot=`test_init double_add`
45 5c99ca9f 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
47 5c99ca9f 2019-03-27 stsp if [ "$ret" != "0" ]; then
48 5c99ca9f 2019-03-27 stsp test_done "$testroot" "$ret"
52 5c99ca9f 2019-03-27 stsp echo "new file" > $testroot/wt/foo
53 5c99ca9f 2019-03-27 stsp (cd $testroot/wt && got add foo > /dev/null)
55 5c99ca9f 2019-03-27 stsp echo "got: File exists" > $testroot/stderr.expected
56 5c99ca9f 2019-03-27 stsp (cd $testroot/wt && got add foo 2> $testroot/stderr)
58 5c99ca9f 2019-03-27 stsp if [ "$ret" == "0" ]; then
59 5c99ca9f 2019-03-27 stsp echo "got add command succeeded unexpectedly" >&2
60 5c99ca9f 2019-03-27 stsp test_done "$testroot" 1
64 5c99ca9f 2019-03-27 stsp cmp $testroot/stderr.expected $testroot/stderr
66 5c99ca9f 2019-03-27 stsp if [ "$ret" != "0" ]; then
67 5c99ca9f 2019-03-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
69 5c99ca9f 2019-03-27 stsp test_done "$testroot" "$ret"
72 6dbf1e9e 2019-03-26 stsp run_test test_add_basic
73 5c99ca9f 2019-03-27 stsp run_test test_double_add