]> arthur.barton.de Git - bup.git/blob - t/test-split-join.sh
test.sh: separate index and split/join tests
[bup.git] / t / test-split-join.sh
1 #!/usr/bin/env bash
2 . wvtest.sh
3 . wvtest-bup.sh
4 . t/lib.sh
5
6 set -o pipefail
7
8 top="$(WVPASS /bin/pwd)" || exit $?
9 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
11
12 bup() { "$top/bup" "$@"; }
13
14 WVPASS cd "$tmpdir"
15
16 WVPASS bup init
17
18 WVSTART "split"
19 WVPASS echo a >a.tmp
20 WVPASS echo b >b.tmp
21 WVPASS bup split -b a.tmp >taga.tmp
22 WVPASS bup split -b b.tmp >tagb.tmp
23 WVPASS cat a.tmp b.tmp | WVPASS bup split -b >tagab.tmp
24 WVPASSEQ $(cat taga.tmp | wc -l) 1
25 WVPASSEQ $(cat tagb.tmp | wc -l) 1
26 WVPASSEQ $(cat tagab.tmp | wc -l) 1
27 WVPASSEQ $(cat tag[ab].tmp | wc -l) 2
28 WVPASSEQ "$(bup split -b a.tmp b.tmp)" "$(cat tagab.tmp)"
29 WVPASSEQ "$(bup split -b --keep-boundaries a.tmp b.tmp)" "$(cat tag[ab].tmp)"
30 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --keep-boundaries --git-ids)" \
31          "$(cat tag[ab].tmp)"
32 WVPASSEQ "$(cat tag[ab].tmp | bup split -b --git-ids)" \
33          "$(cat tagab.tmp)"
34 WVPASS bup split --bench -b <"$top/t/testfile1" >tags1.tmp
35 WVPASS bup split -vvvv -b "$top/t/testfile2" >tags2.tmp
36 WVPASS echo -n "" | WVPASS bup split -n split_empty_string.tmp
37 WVPASS bup margin
38 WVPASS bup midx -f
39 WVPASS bup midx --check -a
40 WVPASS bup midx -o "$BUP_DIR/objects/pack/test1.midx" \
41         "$BUP_DIR"/objects/pack/*.idx
42 WVPASS bup midx --check -a
43 WVPASS bup midx -o "$BUP_DIR"/objects/pack/test1.midx \
44         "$BUP_DIR"/objects/pack/*.idx \
45         "$BUP_DIR"/objects/pack/*.idx
46 WVPASS bup midx --check -a
47 all=$(echo "$BUP_DIR"/objects/pack/*.idx "$BUP_DIR"/objects/pack/*.midx)
48 WVPASS bup midx -o "$BUP_DIR"/objects/pack/zzz.midx $all
49 WVPASS bup tick
50 WVPASS bup midx -o "$BUP_DIR"/objects/pack/yyy.midx $all
51 WVPASS bup midx -a
52 WVPASSEQ "$(echo "$BUP_DIR"/objects/pack/*.midx)" \
53         ""$BUP_DIR"/objects/pack/yyy.midx"
54 WVPASS bup margin
55 WVPASS bup split -t "$top/t/testfile2" >tags2t.tmp
56 WVPASS bup split -t "$top/t/testfile2" --fanout 3 >tags2tf.tmp
57 WVPASS bup split -r "$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
58 WVPASS bup split -r ":$BUP_DIR" -c "$top/t/testfile2" >tags2c.tmp
59 WVPASS ls -lR \
60     | WVPASS bup split -r ":$BUP_DIR" -c --fanout 3 --max-pack-objects 3 -n lslr \
61     || exit $?
62 WVPASS bup ls
63 WVFAIL bup ls /does-not-exist
64 WVPASS bup ls /lslr
65 WVPASS bup ls /lslr/latest
66 WVPASS bup ls /lslr/latest/
67 #WVPASS bup ls /lslr/1971-01-01   # all dates always exist
68 WVFAIL diff -u tags1.tmp tags2.tmp
69
70 # fanout must be different from non-fanout
71 WVFAIL diff tags2t.tmp tags2tf.tmp
72 WVPASS wc -c "$top/t/testfile1" "$top/t/testfile2"
73 WVPASS wc -l tags1.tmp tags2.tmp
74
75 WVSTART "join"
76 WVPASS bup join $(cat tags1.tmp) >out1.tmp
77 WVPASS bup join <tags2.tmp >out2.tmp
78 WVPASS bup join <tags2t.tmp -o out2t.tmp
79 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
80 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
81 WVPASS diff -u "$top/t/testfile1" out1.tmp
82 WVPASS diff -u "$top/t/testfile2" out2.tmp
83 WVPASS diff -u "$top/t/testfile2" out2t.tmp
84 WVPASS diff -u "$top/t/testfile2" out2c.tmp
85 WVPASSEQ "$(bup join split_empty_string.tmp)" ""
86
87 WVPASS rm -rf "$tmpdir"