Test various exclude/include patterns.
[rsync/rsync.git] / testsuite / exclude.test
CommitLineData
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
15set -x
16
17# Build some files/dirs/links to copy
18
19fromdir="$scratchdir/from"
20todir="$scratchdir/to"
21chkdir="$scratchdir/chk"
22
23makepath "$fromdir/foo/down/to/you"
24makepath "$fromdir/bar/down/to/foo/too"
25makepath "$fromdir/mid/for/foo/and/that/is/who"
26echo kept >"$fromdir/foo/file1"
27echo removed >"$fromdir/foo/file2"
28echo keeper >"$fromdir/bar/down/to/foo/file1"
29echo gone >"$fromdir/bar/down/to/foo/file3"
30echo lost >"$fromdir/bar/down/to/foo/file4"
31echo smashed >"$fromdir/bar/down/to/foo/to"
32echo expunged >"$fromdir/mid/for/foo/extra"
33echo retained >"$fromdir/mid/for/foo/keep"
34ln -s too "$fromdir/bar/down/to/foo/sym"
35
36# Setup our test exclude/include file.
37
38# XXX comments reflect up-coming fixed behavior!
39excl="$scratchdir/exclude-from"
40cat >"$excl" <<EOF
41# If the second line of these two lines does anything, it's a bug.
42+ **/bar
43- /bar
44# This should match against the whole path, not just the name.
45+ foo**too
46# This should float at the end of the path.
47- foo/*/
48# Test some normal excludes. Competing lines are paired.
49+ t[o]/
50- to
51+ file4
52- file[2-9]
53- /mid/for/foo/extra
54EOF
55
56# Create the chk dir with what we expect to be excluded
57checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
58
59# Ensure that the following removes will tweak the directory times.
60sleep 1
61
62# XXX Note modified to work with current broken behavior (to be fixed soon!)
63rm -r "$chkdir"/foo/down
64#rm -r "$chkdir"/mid/for/foo/and
65rm "$chkdir"/foo/file[235-9]
66#rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9]
67rm -r "$chkdir"/bar # XXX
68rm "$chkdir"/mid/for/foo/extra
69
70# Make sure that the tweaked dirs times migrate back but nothing else.
71$RSYNC -av --include='*/' --exclude='*' "$chkdir/" "$fromdir/"
72
73# Now, test if rsync excludes the same files
74
75checkit "$RSYNC -avv --exclude-from=$excl \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
76
77exit 0
78# last [] may have failed but if we get here then we've won