X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Fcompare-trees;h=aeaa086a86d1fb92b92bdb902cb34166e42abc44;hb=ae9cde2e3df85569bf76487a9528080926841db5;hp=32edcde2b2d39f4d009d4936b6b672ffb16b0b2a;hpb=96c6fa2a70425fff1e73d2e0945f8e242411ab58;p=bup.git diff --git a/t/compare-trees b/t/compare-trees index 32edcde..aeaa086 100755 --- a/t/compare-trees +++ b/t/compare-trees @@ -1,11 +1,10 @@ #!/usr/bin/env bash +set -u + # Test that src and dest trees are as identical as bup is capable of # making them. For now, use rsync -niaHAX ... -set -e -set -o pipefail - usage() { cat <&2 else - echo "Not comparing xattrs/acls (unsupported by available rsync)." 1>&2 + case $OSTYPE in + cygwin|darwin|netbsd) + echo "Not comparing ACLs (not yet supported on $OSTYPE)" 1>&2 + ;; + *) + rsync_opts="$rsync_opts -A" + ;; + esac fi -rsync $rsync_opts "$src" "$dest" > "${tmpfile}" +xattrs_available='' +if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then + echo "Not comparing xattrs (not supported by available rsync)" 1>&2 +else + xattrs_available=yes +fi + +# Even in dry-run mode, rsync may fail if -X is specified and the +# filesystems don't support xattrs. + +if test "$xattrs_available"; then + rsync $rsync_opts -X "$src" "$dest" > "$tmpfile" + if test $? -ne 0; then + # Try again without -X + rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $? + fi +else + rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $? +fi -if test $(wc -l < "${tmpfile}") != 0; then - echo "Differences between $src and $dest" - cat "${tmpfile}" +if test $(wc -l < "$tmpfile") != 0; then + echo "Differences between $src and $dest" 1>&2 + cat "$tmpfile" exit 1 fi