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 . "$suitedir/rsync.fns"
21 # Build some files/dirs/links to copy
23 echo home-cvs-exclude >"$scratchdir"/.cvsignore
24 makepath "$fromdir/foo/down/to/you"
25 makepath "$fromdir/bar/down/to/foo/too"
26 makepath "$fromdir/mid/for/foo/and/that/is/who"
27 echo kept >"$fromdir/foo/file1"
28 echo removed >"$fromdir/foo/file2"
29 echo cvsout >"$fromdir/foo/file2.old"
30 echo keeper >"$fromdir/bar/down/to/foo/file1"
31 echo cvsout >"$fromdir/bar/down/to/foo/file1.bak"
32 echo gone >"$fromdir/bar/down/to/foo/file3"
33 echo lost >"$fromdir/bar/down/to/foo/file4"
34 echo cvsout >"$fromdir/bar/down/to/foo/file4.junk"
35 echo smashed >"$fromdir/bar/down/to/foo/to"
36 echo cvsout >"$fromdir/bar/down/to/home-cvs-exclude"
37 echo cvsout >"$fromdir/mid/one-in-one-out"
38 echo one-in-one-out >"$fromdir/mid/.cvsignore"
39 echo cvsin >"$fromdir/mid/one-for-all"
40 echo expunged >"$fromdir/mid/for/foo/extra"
41 echo retained >"$fromdir/mid/for/foo/keep"
42 echo cvsin >"$fromdir/mid/for/one-in-one-out"
43 ln -s too "$fromdir/bar/down/to/foo/sym"
45 # Setup our test exclude/include file.
47 excl="$scratchdir/exclude-from"
49 # If the second line of these two lines does anything, it's a bug.
52 # This should match against the whole path, not just the name.
54 # This should float at the end of the path.
56 # Test some normal excludes. Competing lines are paired.
64 # Create the chk dir with what we expect to be excluded
66 checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
68 sleep 1 # Ensures that the rm commands will tweak the directory times.
70 rm -r "$chkdir"/foo/down
71 rm -r "$chkdir"/mid/for/foo/and
72 rm "$chkdir"/foo/file[235-9]
73 rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9]
74 rm "$chkdir"/mid/for/foo/extra
76 # Un-tweak the directory times in our first (weak) exclude test (though
77 # it's a good test of the --existing option).
78 $RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
80 # Now, test if rsync excludes the same files.
82 checkit "$RSYNC -avv --exclude-from=$excl \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
84 # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
86 rm "$chkdir"/foo/*.old
87 rm "$chkdir"/bar/down/to/foo/*.bak
88 rm "$chkdir"/bar/down/to/foo/*.junk
89 rm "$chkdir"/bar/down/to/home-cvs-exclude
90 rm "$chkdir"/mid/one-in-one-out
92 $RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
94 # Now, test if rsync excludes the same files, this time with --cvs-exclude
95 # and --delete-excluded.
97 checkit "$RSYNC -avvC --delete-excluded --exclude-from=$excl \
98 \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
100 # The script would have aborted on error, so getting here means we've won.