]> arthur.barton.de Git - bup.git/blob - test/ext/test-import-duplicity
9374f9a80b4c9054fb6095bb75af4c010f0a2bd7
[bup.git] / test / ext / test-import-duplicity
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3
4 set -o pipefail
5
6 if ! [ "$(type -p duplicity)" != "" ]; then
7     # FIXME: add WVSKIP.
8     echo "Cannot find duplicity; skipping test)" 1>&2
9     exit 0
10 fi
11
12 top="$(WVPASS pwd)" || exit $?
13 tmpdir="$(WVPASS wvmktempdir)" || exit $?
14
15 bup() { "$top/bup" "$@"; }
16 dup() { duplicity --archive-dir "$tmpdir/dup-cache" "$@"; }
17
18 WVSTART "import-duplicity"
19 WVPASS "$top/dev/sync-tree" "$top/test/sampledata/" "$tmpdir/src/"
20
21 export BUP_DIR="$tmpdir/bup"
22 export GIT_DIR="$tmpdir/bup"
23 export PASSPHRASE=bup_duplicity_passphrase
24
25 WVPASS bup init
26 WVPASS cd "$tmpdir"
27 WVPASS mkdir duplicity
28 WVPASS dup src file://duplicity
29 WVPASS bup tick
30 WVPASS touch src/new-file
31 WVPASS dup src file://duplicity
32 WVPASS bup import-duplicity "file://duplicity" import-duplicity
33 WVPASSEQ $(bup ls import-duplicity/ | wc -l) 3
34 WVPASSEQ "$(bup ls import-duplicity/latest/ | sort)" "$(ls src | sort)"
35 WVPASS bup restore -C restore/ import-duplicity/latest/
36 WVFAIL "$top/dev/compare-trees" src/ restore/ > tmp-compare-trees
37 WVPASSEQ $(cat tmp-compare-trees | wc -l) 4
38 # Note: OS X rsync itemize output is currently only 9 chars, not 11.
39 # FreeBSD may output 12 chars instead - accept 9-12
40 # Expect something like this (without the leading spaces):
41 #   .d..t...... ./
42 #   .L..t...... abs-symlink -> /home/foo/bup/test/sampledata/var/abs-symlink-target
43 #   .L..t...... b -> a
44 #   .L..t...... c -> b
45 expected_diff_rx='^\.d\.\.t\.{4,7} \./$|^\.L\.\.t\.{4,7} '
46 if ! grep -qE "$expected_diff_rx" tmp-compare-trees; then
47     echo -n 'tmp-compare-trees: ' 1>&2
48     cat tmp-compare-trees 1>&2
49 fi
50 WVPASS grep -qE "$expected_diff_rx" tmp-compare-trees
51
52 WVPASS rm -rf "$tmpdir"