d57395c9f018dd0c0f1056d0980145545a995b06
[rsync/rsync.git] / testsuite / delete.test
1 #! /bin/sh
2
3 # Copyright (C) 2005 by Wayne Davison <wayned@samba.org>
4
5 # This program is distributable under the terms of the GNU GPL (see
6 # COPYING).
7
8 # Test rsync handling of various delete directives.  
9
10 . "$suitedir/rsync.fns"
11
12 hands_setup
13
14 makepath "$chkdir"
15 makepath "$todir/extradir"
16 makepath "$todir/emptydir/subdir"
17
18 echo extra >"$todir"/remove1
19 echo extra >"$todir"/remove2
20 echo extra >"$todir"/extradir/remove3
21 echo extra >"$todir"/emptydir/subdir/remove4
22
23 # Create two chk dirs, one with a copy of the source files, and one with
24 # what we expect to be left behind by the copy using --remove-source-files.
25 $RSYNC -av "$fromdir/" "$chkdir/copy/"
26 $RSYNC -av -f 'exclude,! */' "$fromdir/" "$chkdir/empty/"
27
28 checkit "$RSYNC -avv --del --remove-source-files \
29     \"$fromdir/\" \"$todir/\"" "$chkdir/copy" "$todir"
30
31 diff -r "$chkdir/empty" "$fromdir"
32
33 # Make sure that "P" but not "-" per-dir merge-file filters take effect with
34 # --delete-excluded.
35 cat >"$todir/filters" <<EOF
36 P foo
37 - bar
38 EOF
39 touch "$todir/foo" "$todir/bar" "$todir/baz"
40
41 $RSYNC -r --exclude=baz --filter=': filters' --delete-excluded "$fromdir/" "$todir/"
42
43 test -f "$todir/foo" || test_fail "rsync deleted $todir/foo"
44 test -f "$todir/bar" && test_fail "rsync did not delete $todir/bar"
45 test -f "$todir/baz" && test_fail "rsync did not delete $todir/baz"
46
47 # The script would have aborted on error, so getting here means we've won.
48 exit 0