Fix compile w/o openssl; disable sha256 & sha512 for --checksum.
[rsync.git] / testsuite / delete.test
blob2a9df7c9497103f01df1d6be7ec461a08034439d
1 #!/bin/sh
3 # Copyright (C) 2005-2022 Wayne Davison
5 # This program is distributable under the terms of the GNU GPL (see
6 # COPYING).
8 # Test rsync handling of various delete directives.
10 . "$suitedir/rsync.fns"
12 hands_setup
14 makepath "$chkdir" "$todir/extradir" "$todir/emptydir/subdir"
16 echo extra >"$todir"/remove1
17 echo extra >"$todir"/remove2
18 echo extra >"$todir"/extradir/remove3
19 echo extra >"$todir"/emptydir/subdir/remove4
21 # Create two chk dirs, one with a copy of the source files, and one with
22 # what we expect to be left behind by the copy using --remove-source-files.
23 # Also, make sure that --dry-run --del doesn't output anything extraneous.
24 $RSYNC -av "$fromdir/" "$chkdir/copy/" >"$tmpdir/copy.out" 2>&1
25 cat "$tmpdir/copy.out"
26 grep -E -v '^(created directory|sent|total size) ' "$tmpdir/copy.out" >"$tmpdir/copy.new"
27 mv "$tmpdir/copy.new" "$tmpdir/copy.out"
29 $RSYNC -avn --del "$fromdir/" "$chkdir/copy2/" >"$tmpdir/copy2.out" 2>&1 || true
30 cat "$tmpdir/copy2.out"
31 grep -E -v '^(created directory|sent|total size) ' "$tmpdir/copy2.out" >"$tmpdir/copy2.new"
32 mv "$tmpdir/copy2.new" "$tmpdir/copy2.out"
34 diff $diffopt "$tmpdir/copy.out" "$tmpdir/copy2.out"
36 $RSYNC -av -f 'exclude,! */' "$fromdir/" "$chkdir/empty/"
38 checkit "$RSYNC -avv --del --remove-source-files '$fromdir/' '$todir/'" "$chkdir/copy" "$todir"
40 diff -r "$chkdir/empty" "$fromdir"
42 # Make sure that "P" but not "-" per-dir merge-file filters take effect with
43 # --delete-excluded.
44 cat >"$todir/filters" <<EOF
45 P foo
46 - bar
47 EOF
48 touch "$todir/foo" "$todir/bar" "$todir/baz"
50 $RSYNC -r --exclude=baz --filter=': filters' --delete-excluded "$fromdir/" "$todir/"
52 test -f "$todir/foo" || test_fail "rsync should NOT have deleted $todir/foo"
53 test -f "$todir/bar" && test_fail "rsync SHOULD have deleted $todir/bar"
54 test -f "$todir/baz" && test_fail "rsync SHOULD have deleted $todir/baz"
56 # The script would have aborted on error, so getting here means we've won.
57 exit 0