+ tmpdir="$(WVPASS wvmktempdir)" || exit $?
+ export BUP_DIR="$tmpdir/bup"
+ WVPASS setup-test-tree
+ WVPASS cd "$tmpdir"
+ WVPASS test-src-save-restore
+
+ # Test a deeper subdir/ to make sure top-level non-dir metadata is
+ # restored correctly. We need at least one dir and one non-dir at
+ # the "top-level".
+ WVPASS test -d src/var/cmd
+ WVPASS test -f src/var/cmd/save-cmd.py
+ WVPASS rm -rf "$BUP_DIR"
+ WVPASS bup init
+ WVPASS touch -t 201111111111 src-restore # Make sure the top won't match.
+ WVPASS bup index src
+ WVPASS bup save -t -n src src
+ WVPASS force-delete src-restore
+ WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/var/."
+ WVPASS touch -t 201211111111 src-restore # Make sure the top won't match.
+ # Check that the only difference is the top dir.
+ WVFAIL $TOP/t/compare-trees -c src/var/ src-restore/ > tmp-compare-trees
+ WVPASSEQ $(cat tmp-compare-trees | wc -l) 1
+ # The number of rsync status characters varies, so accept any
+ # number of trailing dots. For example OS X native rsync produces
+ # 9, but Homebrew's produces 12, while on other platforms, 11 is
+ # common.
+ expected_diff_rx='^\.d\.\.t\.\.\.(\.)+ \./$'
+ if ! grep -qE "$expected_diff_rx" tmp-compare-trees; then
+ echo -n 'tmp-compare-trees: ' 1>&2
+ cat tmp-compare-trees 1>&2
+ fi
+ WVPASS grep -qE "$expected_diff_rx" tmp-compare-trees
+ WVPASS rm -r "$tmpdir"
+) || exit $?