Blame


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