<commit_before>#!/usr/bin/env bash
. ./wvtest-bup.sh || exit $?

set -o pipefail

top="$(WVPASS pwd)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?

export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"

if ! [ "$(type -p duplicity)" != "" ]; then
    # FIXME: add WVSKIP.
    echo "Cannot find duplicity; skipping test)" 1>&2
    exit 0
fi

bup() { "$top/bup" "$@"; }

export PASSPHRASE=bup_duplicity_passphrase
D=duplicity.tmp
WVSTART "import-duplicity"
WVPASS bup init
WVPASS cd "$tmpdir"

dup() { duplicity --archive-dir "$tmpdir/dup-cache" "$@"; }

WVPASS mkdir duplicity
WVPASS dup "$top/lib" file://duplicity
WVPASS bup tick
WVPASS dup "$top/lib" file://duplicity
WVPASS bup import-duplicity "file://duplicity" import-duplicity
WVPASSEQ "$(bup ls import-duplicity/ | wc -l)" "3"
WVPASSEQ "$(bup ls import-duplicity/latest/ | sort)" "$(ls "$top/lib" | sort)"
WVPASS bup restore -C restore/ import-duplicity/latest/
WVPASS diff -ruN "$top/lib" restore

WVPASS rm -rf "$tmpdir"<commit_msg>test-import-duplicity: use install tree for data<commit_after>#!/usr/bin/env bash
. ./wvtest-bup.sh || exit $?

set -o pipefail

if ! [ "$(type -p duplicity)" != "" ]; then
    # FIXME: add WVSKIP.
    echo "Cannot find duplicity; skipping test)" 1>&2
    exit 0
fi

top="$(WVPASS pwd)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?

bup() { "$top/bup" "$@"; }
dup() { duplicity --archive-dir "$tmpdir/dup-cache" "$@"; }

WVSTART "import-duplicity"
WVPASS make install DESTDIR="$tmpdir/src"

export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"
export PASSPHRASE=bup_duplicity_passphrase

WVPASS bup init
WVPASS cd "$tmpdir"
WVPASS mkdir duplicity
WVPASS dup src file://duplicity
WVPASS bup tick
WVPASS touch src/new-file
WVPASS dup src file://duplicity
WVPASS bup import-duplicity "file://duplicity" import-duplicity
WVPASSEQ "$(bup ls import-duplicity/ | wc -l)" "3"
WVPASSEQ "$(bup ls import-duplicity/latest/ | sort)" "$(ls src | sort)"
WVPASS bup restore -C restore/ import-duplicity/latest/
WVFAIL "$top/t/compare-trees" src/ restore/ > tmp-compare-trees
WVPASSEQ $(cat tmp-compare-trees | wc -l) 1
# Note: OS X rsync itemize output is currently only 9 chars, not 11.
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 -rf "$tmpdir"
{'fraction_non_alphanumeric': 0.17007358953393295, 'fraction_numerical': 0.006541291905151268, 'mean_word_length': 4.066252587991719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4482156', 'n_tokens_mistral': 995, 'n_tokens_neox': 942, 'n_words': 253}