]> arthur.barton.de Git - bup.git/blob - t/test-import-duplicity.sh
Use t/sampledata, not make install, for tests
[bup.git] / t / test-import-duplicity.sh
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 cp -a "$top/t/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/t/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 # Expect something like this (without the leading spaces):
40 #   .d..t...... ./
41 #   .L..t...... abs-symlink -> /home/foo/bup/t/sampledata/var/abs-symlink-target
42 #   .L..t...... b -> a
43 #   .L..t...... c -> b
44 expected_diff_rx='^\.d\.\.t.\.\.\.\.?\.? \./$|^\.L\.\.t.\.\.\.\.?\.? '
45 if ! grep -qE "$expected_diff_rx" tmp-compare-trees; then
46     echo -n 'tmp-compare-trees: ' 1>&2
47     cat tmp-compare-trees 1>&2
48 fi
49 WVPASS grep -qE "$expected_diff_rx" tmp-compare-trees
50
51 WVPASS rm -rf "$tmpdir"