]> arthur.barton.de Git - bup.git/blob - test/ext/test-import-duplicity
Teach pytest to handle WVSKIP and use it where we can
[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     WVSKIP 'Cannot find duplicity; skipping test)'
8     exit 0
9 fi
10
11 top="$(WVPASS pwd)" || exit $?
12 tmpdir="$(WVPASS wvmktempdir)" || exit $?
13
14 bup() { "$top/bup" "$@"; }
15 dup() { duplicity --archive-dir "$tmpdir/dup-cache" "$@"; }
16
17 WVSTART "import-duplicity"
18 WVPASS "$top/dev/sync-tree" "$top/test/sampledata/" "$tmpdir/src/"
19
20 export BUP_DIR="$tmpdir/bup"
21 export GIT_DIR="$tmpdir/bup"
22 export PASSPHRASE=bup_duplicity_passphrase
23
24 WVPASS bup init
25 WVPASS cd "$tmpdir"
26 WVPASS mkdir duplicity
27 WVPASS dup src file://duplicity
28 WVPASS bup tick
29 WVPASS touch src/new-file
30 WVPASS dup src file://duplicity
31 WVPASS bup import-duplicity "file://duplicity" import-duplicity
32 WVPASSEQ $(bup ls import-duplicity/ | wc -l) 3
33 WVPASSEQ "$(bup ls import-duplicity/latest/ | sort)" "$(ls src | sort)"
34 WVPASS bup restore -C restore/ import-duplicity/latest/
35 WVFAIL "$top/dev/compare-trees" src/ restore/ > tmp-compare-trees
36 WVPASSEQ $(cat tmp-compare-trees | wc -l) 4
37 # Note: OS X rsync itemize output is currently only 9 chars, not 11.
38 # FreeBSD may output 12 chars instead - accept 9-12
39 # Expect something like this (without the leading spaces):
40 #   .d..t...... ./
41 #   .L..t...... abs-symlink -> /home/foo/bup/test/sampledata/var/abs-symlink-target
42 #   .L..t...... b -> a
43 #   .L..t...... c -> b
44 expected_diff_rx='^\.d\.\.t\.{4,7} \./$|^\.L\.\.t\.{4,7} '
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"