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 17ed4618 2019-06-02 stsp echo 'D alpha' > $testroot/stdout.expected
30 17ed4618 2019-06-02 stsp echo 'D beta' >> $testroot/stdout.expected
31 17ed4618 2019-06-02 stsp (cd $testroot/wt && got rm alpha beta > $testroot/stdout)
33 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
35 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
36 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
37 17ed4618 2019-06-02 stsp test_done "$testroot" "$ret"
41 17ed4618 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
43 17ed4618 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
45 17ed4618 2019-06-02 stsp if [ "$ret" != "0" ]; then
46 17ed4618 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
47 17ed4618 2019-06-02 stsp test_done "$testroot" "$ret"
51 17ed4618 2019-06-02 stsp for f in alpha beta; do
52 17ed4618 2019-06-02 stsp if [ -e $testroot/wt/$f ]; then
53 17ed4618 2019-06-02 stsp echo "removed file $f still exists on disk" >&2
54 17ed4618 2019-06-02 stsp test_done "$testroot" "1"
59 17ed4618 2019-06-02 stsp test_done "$testroot" "0"
62 2ec1f75b 2019-03-26 stsp function test_rm_with_local_mods {
63 2ec1f75b 2019-03-26 stsp local testroot=`test_init rm_with_local_mods`
65 2ec1f75b 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
67 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
68 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
72 2ec1f75b 2019-03-26 stsp echo "modified beta" > $testroot/wt/beta
73 2ec1f75b 2019-03-26 stsp echo 'got: file contains modifications' > $testroot/stderr.expected
74 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm beta 2>$testroot/stderr)
76 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
78 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
79 2ec1f75b 2019-03-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
80 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
84 2ec1f75b 2019-03-26 stsp echo 'D beta' > $testroot/stdout.expected
85 2ec1f75b 2019-03-26 stsp (cd $testroot/wt && got rm -f beta > $testroot/stdout)
87 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
89 2ec1f75b 2019-03-26 stsp if [ "$ret" != "0" ]; then
90 2ec1f75b 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
93 2ec1f75b 2019-03-26 stsp if [ -e $testroot/wt/beta ]; then
94 2ec1f75b 2019-03-26 stsp echo "removed file beta still exists on disk" >&2
95 2ec1f75b 2019-03-26 stsp test_done "$testroot" "1"
99 2ec1f75b 2019-03-26 stsp test_done "$testroot" "$ret"
102 71a29355 2019-03-27 stsp function test_double_rm {
103 71a29355 2019-03-27 stsp local testroot=`test_init double_rm`
105 71a29355 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
107 71a29355 2019-03-27 stsp if [ "$ret" != "0" ]; then
108 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
112 71a29355 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
114 71a29355 2019-03-27 stsp for fflag in "" "-f"; do
115 71a29355 2019-03-27 stsp (cd $testroot/wt && got rm $fflag beta 2> $testroot/stderr)
117 71a29355 2019-03-27 stsp if [ "$ret" == "0" ]; then
118 71a29355 2019-03-27 stsp echo "got rm command succeeded unexpectedly" >&2
119 71a29355 2019-03-27 stsp test_done "$testroot" 1
122 2af4a041 2019-05-11 jcs grep "No such file or directory" $testroot/stderr > \
123 2af4a041 2019-05-11 jcs $testroot/stderr.actual
125 71a29355 2019-03-27 stsp if [ "$ret" != "0" ]; then
126 2af4a041 2019-05-11 jcs cat $testroot/stderr
127 71a29355 2019-03-27 stsp test_done "$testroot" "$ret"
130 71a29355 2019-03-27 stsp test_done "$testroot" "0"
133 2ec1f75b 2019-03-26 stsp run_test test_rm_basic
134 2ec1f75b 2019-03-26 stsp run_test test_rm_with_local_mods
135 71a29355 2019-03-27 stsp run_test test_double_rm