From 701b158eb6fcbbffcbdcc88018387341a9dfa47a Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 21 Mar 2015 17:17:12 -0500 Subject: [PATCH] Use t/sampledata, not make install, for tests This should be more efficient, and is intended fix the problems people have experienced with the recursive "make install" invocations that some tests were using to produce input data. Signed-off-by: Rob Browning Tested-by: Rob Browning --- t/configure-sampledata | 6 +++++- t/test-fsck.sh | 12 ++++++------ t/test-import-duplicity.sh | 11 ++++++++--- t/test-meta.sh | 10 +++++----- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/t/configure-sampledata b/t/configure-sampledata index c95d936..256d0bf 100755 --- a/t/configure-sampledata +++ b/t/configure-sampledata @@ -5,7 +5,7 @@ set -o pipefail # NOTE: any relevant changes to var/ must be accompanied by an # increment to the revision. -revision=0 +revision=1 readonly revision top="$(pwd)" || exit $? @@ -41,6 +41,10 @@ case "$1" in ln -sf a b || exit $? ln -sf b c || exit $? ln -sf "$(pwd)/abs-symlink-target" abs-symlink || exit $? + mkdir -p cmd doc lib/bup || exit $? + cp -a "$top"/cmd/*.py cmd/ || exit $? + cp -a "$top"/Documentation/*.md doc/ || exit $? + cp -a "$top"/lib/bup/*.py lib/bup || exit $? # The "v" ensures that if "configure-sampledata # --revision" and/or the setup above fails somehow, # callers like make will be looking for a file that won't diff --git a/t/test-fsck.sh b/t/test-fsck.sh index 27f103a..22d909c 100755 --- a/t/test-fsck.sh +++ b/t/test-fsck.sh @@ -8,8 +8,7 @@ tmpdir="$(WVPASS wvmktempdir)" || exit $? bup() { "$top/bup" "$@"; } -WVPASS make install DESTDIR="$tmpdir/src" -WVPASS cp -a "$top/t/sampledata" "$tmpdir/src/" +WVPASS cp -a "$top/t/sampledata" "$tmpdir/src" export BUP_DIR="$tmpdir/bup" export GIT_DIR="$tmpdir/bup" @@ -20,10 +19,11 @@ WVPASS cd "$tmpdir" WVSTART "fsck" WVPASS bup index src -WVPASS bup save -n fsck-test src/sampledata -WVPASS bup save -n fsck-test src/usr/bin -WVPASS bup save -n fsck-test src/usr/lib -WVPASS bup save -n fsck-test src/usr/share +WVPASS bup save -n fsck-test src/b2 +WVPASS bup save -n fsck-test src/var/cmd +WVPASS bup save -n fsck-test src/var/doc +WVPASS bup save -n fsck-test src/var/lib +WVPASS bup save -n fsck-test src/y WVPASS bup fsck WVPASS bup fsck --quick if bup fsck --par2-ok; then diff --git a/t/test-import-duplicity.sh b/t/test-import-duplicity.sh index 8931c08..61fb2ff 100755 --- a/t/test-import-duplicity.sh +++ b/t/test-import-duplicity.sh @@ -16,7 +16,7 @@ bup() { "$top/bup" "$@"; } dup() { duplicity --archive-dir "$tmpdir/dup-cache" "$@"; } WVSTART "import-duplicity" -WVPASS make install DESTDIR="$tmpdir/src" +WVPASS cp -a "$top/t/sampledata" "$tmpdir/src" export BUP_DIR="$tmpdir/bup" export GIT_DIR="$tmpdir/bup" @@ -34,9 +34,14 @@ 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 +WVPASSEQ $(cat tmp-compare-trees | wc -l) 4 # Note: OS X rsync itemize output is currently only 9 chars, not 11. -expected_diff_rx='^\.d\.\.t.\.\.\.\.?\.? \./$' +# Expect something like this (without the leading spaces): +# .d..t...... ./ +# .L..t...... abs-symlink -> /home/foo/bup/t/sampledata/var/abs-symlink-target +# .L..t...... b -> a +# .L..t...... c -> b +expected_diff_rx='^\.d\.\.t.\.\.\.\.?\.? \./$|^\.L\.\.t.\.\.\.\.?\.? ' if ! grep -qE "$expected_diff_rx" tmp-compare-trees; then echo -n 'tmp-compare-trees: ' 1>&2 cat tmp-compare-trees 1>&2 diff --git a/t/test-meta.sh b/t/test-meta.sh index 573ad8c..f9fa896 100755 --- a/t/test-meta.sh +++ b/t/test-meta.sh @@ -100,7 +100,7 @@ test-src-save-restore() setup-test-tree() { - WVPASS make PREFIX="$tmpdir"/src install + WVPASS cp -a "$TOP/t/sampledata" "$tmpdir/src" # Add some hard links for the general tests. ( @@ -158,18 +158,18 @@ WVSTART 'metadata save/restore (general)' # Test a deeper subdir/ to make sure top-level non-dir metadata is # restored correctly. We need at least one dir and one non-dir at # the "top-level". - WVPASS test -d src/bin - WVPASS test -f src/bin/bup + WVPASS test -d src/var/cmd + WVPASS test -f src/var/cmd/save-cmd.py WVPASS rm -rf "$BUP_DIR" WVPASS bup init WVPASS touch -t 201111111111 src-restore # Make sure the top won't match. WVPASS bup index src WVPASS bup save -t -n src src WVPASS force-delete src-restore - WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/lib/" + WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/var/." WVPASS touch -t 201211111111 src-restore # Make sure the top won't match. # Check that the only difference is the top dir. - WVFAIL $TOP/t/compare-trees -c src/lib/ src-restore/ > tmp-compare-trees + WVFAIL $TOP/t/compare-trees -c src/var/ 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.\.\.\.\.?\.? \./$' -- 2.39.2