]> arthur.barton.de Git - bup.git/blob - t/test-on.sh
t/test-on.sh: Don't quote "wc -l" output
[bup.git] / t / test-on.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3 . ./t/lib.sh || exit $?
4
5 set -o pipefail
6
7 top="$(WVPASS pwd)" || exit $?
8 tmpdir="$(WVPASS wvmktempdir)" || exit $?
9
10 export BUP_DIR="$tmpdir/bup"
11 export GIT_DIR="$tmpdir/bup"
12
13 bup() { "$top/bup" "$@"; }
14 compare-trees() { "$top/t/compare-trees" "$@"; }
15
16 WVPASS bup init
17 WVPASS cd "$tmpdir"
18
19 WVSTART "index/save"
20 WVPASS mkdir src src/foo
21 WVPASS date > src/bar
22 WVPASS bup random 1k > src/baz
23 WVPASS bup on - index src
24 WVPASS bup on - save -ctn src src > get.log
25 WVPASSEQ $(WVPASS cat get.log | WVPASS wc -l) 2
26 tree_id=$(WVPASS awk 'FNR == 1' get.log) || exit $?
27 commit_id=$(WVPASS awk 'FNR == 2' get.log) || exit $?
28 WVPASS git ls-tree "$tree_id"
29 WVPASS git cat-file commit "$commit_id" | head -n 1 \
30     | WVPASS grep "^tree $tree_id\$"
31
32 WVPASS bup restore -C restore "src/latest/$(pwd)/src/."
33 WVPASS compare-trees src/ restore/
34 WVPASS rm -r restore
35
36 WVSTART "split"
37 WVPASS bup on - split -ctn baz src/baz > get.log
38 tree_id=$(WVPASS awk 'FNR == 1' get.log) || exit $?
39 commit_id=$(WVPASS awk 'FNR == 2' get.log) || exit $?
40 WVPASS git ls-tree "$tree_id"
41 WVPASS git cat-file commit "$commit_id" | head -n 1 \
42     | WVPASS grep "^tree $tree_id\$"
43 WVPASS bup join baz > restore-baz
44 WVPASS cmp src/baz restore-baz
45
46 WVPASS rm -rf "$tmpdir"