Commit | Line | Data |
---|---|---|
ff570659 WD |
1 | #! /bin/sh |
2 | ||
3 | # Copyright (C) 2003 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 exclude/include directives. | |
9 | ||
10 | # Test some of the more obscure wildcard handling of exclude/include | |
11 | # processing. | |
12 | ||
13 | . $srcdir/testsuite/rsync.fns | |
14 | ||
15 | set -x | |
16 | ||
17 | # Build some files/dirs/links to copy | |
18 | ||
19 | fromdir="$scratchdir/from" | |
20 | todir="$scratchdir/to" | |
21 | chkdir="$scratchdir/chk" | |
22 | ||
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" | |
35 | ||
36 | # Setup our test exclude/include file. | |
37 | ||
ff570659 WD |
38 | excl="$scratchdir/exclude-from" |
39 | cat >"$excl" <<EOF | |
40 | # If the second line of these two lines does anything, it's a bug. | |
41 | + **/bar | |
42 | - /bar | |
43 | # This should match against the whole path, not just the name. | |
44 | + foo**too | |
45 | # This should float at the end of the path. | |
46 | - foo/*/ | |
47 | # Test some normal excludes. Competing lines are paired. | |
48 | + t[o]/ | |
49 | - to | |
50 | + file4 | |
51 | - file[2-9] | |
52 | - /mid/for/foo/extra | |
53 | EOF | |
54 | ||
55 | # Create the chk dir with what we expect to be excluded | |
337a1a86 | 56 | |
ff570659 WD |
57 | checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir" |
58 | ||
337a1a86 | 59 | sleep 1 # Ensures that the rm commands will tweak the directory times. |
ff570659 | 60 | |
ff570659 | 61 | rm -r "$chkdir"/foo/down |
093acc5d | 62 | rm -r "$chkdir"/mid/for/foo/and |
ff570659 | 63 | rm "$chkdir"/foo/file[235-9] |
093acc5d | 64 | rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9] |
ff570659 WD |
65 | rm "$chkdir"/mid/for/foo/extra |
66 | ||
337a1a86 WD |
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/" | |
ff570659 | 70 | |
337a1a86 | 71 | # Now, test if rsync excludes the same files. |
ff570659 WD |
72 | |
73 | checkit "$RSYNC -avv --exclude-from=$excl \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir" | |
74 | ||
75 | exit 0 |