3 2ec1f75b 2019-03-26 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 2ec1f75b 2019-03-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 2ec1f75b 2019-03-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 2ec1f75b 2019-03-26 stsp # copyright notice and this permission notice appear in all copies.
9 2ec1f75b 2019-03-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 2ec1f75b 2019-03-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 2ec1f75b 2019-03-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 2ec1f75b 2019-03-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 2ec1f75b 2019-03-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 2ec1f75b 2019-03-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 2ec1f75b 2019-03-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 2ec1f75b 2019-03-26 stsp . ./common.sh
19 2ec1f75b 2019-03-26 stsp function test_rm_basic {
20 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_basic`
22 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
25 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
29 2ec1f75b 2019-03-26 stsp echo 'D beta' > $testroot/stdout.expected
30 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm beta > $testroot/stdout)
32 2ec1f75b 2019-03-26 stsp cmp $testroot/stdout.expected $testroot/stdout
34 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
35 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
38 2ec1f75b 2019-03-26 stsp if [ -e $testroot/wt/beta ]; then
39 2ec1f75b 2019-03-26 stsp echo "removed file beta still exists on disk" >&2
40 2ec1f75b 2019-03-26 stsp test_done "$testroot" "1"
44 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
47 2ec1f75b 2019-03-26 stsp function test_rm_with_local_mods {
48 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_with_local_mods`
50 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
52 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
53 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
57 2ec1f75b 2019-03-26 stsp echo "modified beta" > $testroot/wt/beta
58 2ec1f75b 2019-03-26 stsp echo 'got: file contains modifications' > $testroot/stderr.expected
59 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm beta 2>$testroot/stderr)
61 2ec1f75b 2019-03-26 stsp cmp $testroot/stderr.expected $testroot/stderr
63 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
64 2ec1f75b 2019-03-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
65 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
69 2ec1f75b 2019-03-26 stsp echo 'D beta' > $testroot/stdout.expected
70 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm -f beta > $testroot/stdout)
72 2ec1f75b 2019-03-26 stsp cmp $testroot/stdout.expected $testroot/stdout
74 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
75 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
78 2ec1f75b 2019-03-26 stsp if [ -e $testroot/wt/beta ]; then
79 2ec1f75b 2019-03-26 stsp echo "removed file beta still exists on disk" >&2
80 2ec1f75b 2019-03-26 stsp test_done "$testroot" "1"
84 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
87 71a29355 2019-03-27 stsp function test_double_rm {
88 71a29355 2019-03-27 stsp local testroot=`test_init double_rm`
90 71a29355 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
92 71a29355 2019-03-27 stsp if [ "$ret" != "0" ]; then
93 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
97 71a29355 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
99 71a29355 2019-03-27 stsp for fflag in "" "-f"; do
100 71a29355 2019-03-27 stsp echo "got: No such file or directory" > $testroot/stderr.expected
101 71a29355 2019-03-27 stsp (cd $testroot/wt && got rm $fflag beta 2> $testroot/stderr)
103 71a29355 2019-03-27 stsp if [ "$ret" == "0" ]; then
104 71a29355 2019-03-27 stsp echo "got rm command succeeded unexpectedly" >&2
105 71a29355 2019-03-27 stsp test_done "$testroot" 1
108 71a29355 2019-03-27 stsp cmp $testroot/stderr.expected $testroot/stderr
110 71a29355 2019-03-27 stsp if [ "$ret" != "0" ]; then
111 71a29355 2019-03-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
112 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
115 71a29355 2019-03-27 stsp test_done "$testroot" "0"
118 2ec1f75b 2019-03-26 stsp run_test test_rm_basic
119 2ec1f75b 2019-03-26 stsp run_test test_rm_with_local_mods
120 71a29355 2019-03-27 stsp run_test test_double_rm