3 # Copyright (C) 2003 by Wayne Davison <wayned@samba.org>
5 # This program is distributable under the terms of the GNU GPL see
8 # Test rsync handling of exclude/include directives.
10 # Test some of the more obscure wildcard handling of exclude/include
13 . $srcdir/testsuite/rsync.fns
17 # Build some files/dirs/links to copy
19 fromdir="$scratchdir/from"
20 todir="$scratchdir/to"
21 chkdir="$scratchdir/chk"
23 makepath "$fromdir/foo/down/to/you"
24 makepath "$fromdir/bar/down/to/foo/too"
25 makepath "$fromdir/mid/for/foo/and/that/is/who"
26 echo kept >"$fromdir/foo/file1"
27 echo removed >"$fromdir/foo/file2"
28 echo keeper >"$fromdir/bar/down/to/foo/file1"
29 echo gone >"$fromdir/bar/down/to/foo/file3"
30 echo lost >"$fromdir/bar/down/to/foo/file4"
31 echo smashed >"$fromdir/bar/down/to/foo/to"
32 echo expunged >"$fromdir/mid/for/foo/extra"
33 echo retained >"$fromdir/mid/for/foo/keep"
34 ln -s too "$fromdir/bar/down/to/foo/sym"
36 # Setup our test exclude/include file.
38 excl="$scratchdir/exclude-from"
40 # If the second line of these two lines does anything, it's a bug.
43 # This should match against the whole path, not just the name.
45 # This should float at the end of the path.
47 # Test some normal excludes. Competing lines are paired.
55 # Create the chk dir with what we expect to be excluded
57 checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
59 sleep 1 # Ensures that the rm commands will tweak the directory times.
61 rm -r "$chkdir"/foo/down
62 rm -r "$chkdir"/mid/for/foo/and
63 rm "$chkdir"/foo/file[235-9]
64 rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9]
65 rm "$chkdir"/mid/for/foo/extra
67 # Un-tweak the directory times in our first (weak) exclude test (though
68 # it's a good test of the --existing option).
69 $RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
71 # Now, test if rsync excludes the same files.
73 checkit "$RSYNC -avv --exclude-from=$excl \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"