]> arthur.barton.de Git - bup.git/commitdiff
Move compression tests from test.sh to test-compression.sh.
authorRob Browning <rlb@defaultvalue.org>
Tue, 31 Dec 2013 18:33:39 +0000 (12:33 -0600)
committerRob Browning <rlb@defaultvalue.org>
Tue, 31 Dec 2013 18:33:39 +0000 (12:33 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
t/test-compression.sh [new file with mode: 0755]
t/test.sh

index 0fe347550d063e1c5b531afbcdbdcf057b23b703..1935d74b1465a2dc84d4c20f788d3450760f26b8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,7 @@ runtests-python: all
 runtests-cmdline: all
        test -e t/tmp || mkdir t/tmp
        TMPDIR="$(test_tmp)" t/test-cat-file.sh
+       TMPDIR="$(test_tmp)" t/test-compression.sh
        TMPDIR="$(test_tmp)" t/test-index-check-device.sh
        TMPDIR="$(test_tmp)" t/test-meta.sh
        TMPDIR="$(test_tmp)" t/test-restore-map-owner.sh
diff --git a/t/test-compression.sh b/t/test-compression.sh
new file mode 100755 (executable)
index 0000000..9e3c02d
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+. ./wvtest-bup.sh
+. t/lib.sh
+
+set -o pipefail
+
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
+
+export BUP_DIR="$tmpdir/bup"
+export GIT_DIR="$tmpdir/bup"
+
+bup() { "$top/bup" "$@"; }
+
+WVSTART "compression"
+WVPASS cd "$tmpdir"
+
+D=compression0.tmp
+WVPASS force-delete "$BUP_DIR"
+WVPASS bup init
+WVPASS mkdir $D
+WVPASS bup index "$top/Documentation"
+WVPASS bup save -n compression -0 --strip "$top/Documentation"
+# Some platforms set -A by default when root, so just use it everywhere.
+expected="$(WVPASS ls -A "$top/Documentation" | WVPASS sort)" || exit $?
+actual="$(WVPASS bup ls -A compression/latest/ | WVPASS sort)" || exit $?
+WVPASSEQ "$actual" "$expected"
+compression_0_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $?
+
+D=compression9.tmp
+WVPASS force-delete "$BUP_DIR"
+WVPASS bup init
+WVPASS mkdir $D
+WVPASS bup index "$top/Documentation"
+WVPASS bup save -n compression -9 --strip "$top/Documentation"
+expected="$(ls -A "$top/Documentation" | sort)" || exit $?
+actual="$(bup ls -A compression/latest/ | sort)" || exit $?
+WVPASSEQ "$actual" "$expected"
+compression_9_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $?
+
+WVPASS [ "$compression_9_size" -lt "$compression_0_size" ]
+
+
+WVPASS rm -rf "$tmpdir"
index 9c344e24b4b305e1e8ce4b932f305609834565be..3483a3f6cfe1847b37042fe98c7bb9faa6cd77c5 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -451,36 +451,6 @@ WVPASSEQ "$(bup ls -F buptest/latest/)" "a/
 c/"
 
 
-WVSTART "compression"
-D=compression0.tmp
-export BUP_DIR="$TOP/$D/.bup"
-WVPASS force-delete $D
-WVPASS mkdir $D
-WVPASS bup init
-WVPASS bup index $TOP/Documentation
-WVPASS bup save -n compression -0 --strip $TOP/Documentation
-# 'ls' on NetBSD sets -A by default when running as root, so we have to undo
-# it by grepping out any dotfiles.  (Normal OSes don't auto-set -A, but this
-# is harmless there.)
-expected="$(WVPASS ls $TOP/Documentation | grep -v '^\.' | WVPASS sort)" \
-    || exit $?
-actual="$(WVPASS bup ls compression/latest/ | WVPASS sort)" || exit $?
-WVPASSEQ "$actual" "$expected"
-COMPRESSION_0_SIZE=$(WVPASS du -k -s $D | WVPASS cut -f1) || exit $?
-
-D=compression9.tmp
-export BUP_DIR="$TOP/$D/.bup"
-WVPASS force-delete $D
-WVPASS mkdir $D
-WVPASS bup init
-WVPASS bup index $TOP/Documentation
-WVPASS bup save -n compression -9 --strip $TOP/Documentation
-WVPASSEQ "$(bup ls compression/latest/ | sort)" \
-         "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
-COMPRESSION_9_SIZE=$(WVPASS du -k -s $D | WVPASS cut -f1) || exit $?
-
-WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
-
 WVSTART "save disjoint top-level directories"
 (
     # Resolve any symlinks involving the top top-level dirs.