Updated the --max-delete docs.
[rsync/rsync.git] / testsuite / delete.test
CommitLineData
0254bd46
WD
1#! /bin/sh
2
3# Copyright (C) 2005 by Wayne Davison <wayned@samba.org>
4
c8d19f90 5# This program is distributable under the terms of the GNU GPL (see
0254bd46
WD
6# COPYING).
7
8# Test rsync handling of various delete directives.
9
10. "$suitedir/rsync.fns"
11
12hands_setup
13
7ea6ea98 14makepath "$chkdir" "$todir/extradir" "$todir/emptydir/subdir"
9ba53f26
WD
15
16echo extra >"$todir"/remove1
17echo extra >"$todir"/remove2
18echo extra >"$todir"/extradir/remove3
19echo extra >"$todir"/emptydir/subdir/remove4
0254bd46
WD
20
21# Create two chk dirs, one with a copy of the source files, and one with
c63625d4 22# what we expect to be left behind by the copy using --remove-source-files.
952ae751
WD
23# Also, make sure that --dry-run --del doesn't output anything extraneous.
24$RSYNC -av "$fromdir/" "$chkdir/copy/" >"$tmpdir/copy.out" 2>&1
25cat "$tmpdir/copy.out"
26grep -v '^\(created directory\|sent\|total size\) ' "$tmpdir/copy.out" >"$tmpdir/copy.new"
27mv "$tmpdir/copy.new" "$tmpdir/copy.out"
28
29$RSYNC -avn --del "$fromdir/" "$chkdir/copy2/" >"$tmpdir/copy2.out" 2>&1 || true
30cat "$tmpdir/copy2.out"
31grep -v '^\(created directory\|sent\|total size\) ' "$tmpdir/copy2.out" >"$tmpdir/copy2.new"
32mv "$tmpdir/copy2.new" "$tmpdir/copy2.out"
33
34diff $diffopt "$tmpdir/copy.out" "$tmpdir/copy2.out"
35
0254bd46
WD
36$RSYNC -av -f 'exclude,! */' "$fromdir/" "$chkdir/empty/"
37
c63625d4 38checkit "$RSYNC -avv --del --remove-source-files \
0254bd46
WD
39 \"$fromdir/\" \"$todir/\"" "$chkdir/copy" "$todir"
40
41diff -r "$chkdir/empty" "$fromdir"
42
814b340c
WD
43# Make sure that "P" but not "-" per-dir merge-file filters take effect with
44# --delete-excluded.
ff43d8b4
WD
45cat >"$todir/filters" <<EOF
46P foo
814b340c 47- bar
ff43d8b4 48EOF
814b340c 49touch "$todir/foo" "$todir/bar" "$todir/baz"
ff43d8b4 50
814b340c 51$RSYNC -r --exclude=baz --filter=': filters' --delete-excluded "$fromdir/" "$todir/"
ff43d8b4 52
48ffc11e
WD
53test -f "$todir/foo" || test_fail "rsync should NOT have deleted $todir/foo"
54test -f "$todir/bar" && test_fail "rsync SHOULD have deleted $todir/bar"
55test -f "$todir/baz" && test_fail "rsync SHOULD have deleted $todir/baz"
ff43d8b4 56
0254bd46
WD
57# The script would have aborted on error, so getting here means we've won.
58exit 0