From: Rob Browning Date: Sat, 21 Mar 2015 19:57:18 +0000 (-0500) Subject: Create t/sampledata/var/ and version it X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5515c60cbf4e6ce4097e3c97b124cace7ef3f2d0;p=packages%2Fb%2Fbup.git Create t/sampledata/var/ and version it Maintain a new t/sampledata/var/ (via t/configure-sampledata) that contains any test data that we don't want to or can't commit to git (i.e. symlinks, and other dynamically generated data). Move all of the existing generated data there, and delete var/ entirely on clean. Control the creation of var/ with make, via the existence of t/sampledata/var/rev/vN. Whenever we change the content, we'll change N (currently 0), which will force the directory to be recreated. Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/Makefile b/Makefile index ffb4627..5bc3bcc 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ + +sampledata_rev := $(shell t/configure-sampledata --revision) +current_sampledata := t/sampledata/var/rev/v$(sampledata_rev) + OS:=$(shell uname | sed 's/[-_].*//') CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS) CFLAGS := -D_FILE_OFFSET_BITS=64 $(CFLAGS) @@ -15,15 +19,16 @@ endif bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds -.PHONY: all -all: $(bup_deps) Documentation/all - t/configure-sampledata --setup +all: $(bup_deps) Documentation/all $(current_sampledata) bup: ln -s main.py bup Documentation/all: $(bup_deps) +$(current_sampledata): + t/configure-sampledata --setup + INSTALL=install PYTHON=python PREFIX=/usr diff --git a/lib/bup/t/tindex.py b/lib/bup/t/tindex.py index 3ec4939..106d0fe 100644 --- a/lib/bup/t/tindex.py +++ b/lib/bup/t/tindex.py @@ -16,10 +16,10 @@ def index_basic(): sd = os.path.realpath(cd + '/sampledata') WVPASSEQ(index.realpath(cd + '/sampledata'), sd) WVPASSEQ(os.path.realpath(cd + '/sampledata/x'), sd + '/x') - WVPASSEQ(os.path.realpath(cd + '/sampledata/abs-symlink'), - sd + '/abs-symlink-target') - WVPASSEQ(index.realpath(cd + '/sampledata/abs-symlink'), - sd + '/abs-symlink') + WVPASSEQ(os.path.realpath(cd + '/sampledata/var/abs-symlink'), + sd + '/var/abs-symlink-target') + WVPASSEQ(index.realpath(cd + '/sampledata/var/abs-symlink'), + sd + '/var/abs-symlink') @wvtest diff --git a/t/configure-sampledata b/t/configure-sampledata index d884727..c95d936 100755 --- a/t/configure-sampledata +++ b/t/configure-sampledata @@ -2,36 +2,57 @@ set -o pipefail -top=$(pwd) +# NOTE: any relevant changes to var/ must be accompanied by an +# increment to the revision. + +revision=0 +readonly revision + +top="$(pwd)" || exit $? usage() { - echo 'Usage: t/configure-sampledata [--setup | --clean]' + echo 'Usage: t/configure-sampledata [--setup | --clean | --revision]' } if test "$#" -ne 1; then usage 1>&2; exit 1 fi +clean() +( + cd t/sampledata || exit $? + if test -e var; then rm -r var || exit $?; fi + # Remove legacy content (before everything moved to var/). + # test -e is false for dangling symlinks. + if test -h b -o -e b; then rm b || exit $?; fi + if test -h c -o -e c; then rm c || exit $?; fi + if test -h abs-symlink -o -e abs-symlink; then + rm abs-symlink || exit $? + fi +) + case "$1" in - '--setup') + --setup) ( - cd t/sampledata || exit $? + clean + mkdir -p t/sampledata/var/rev || exit $? + cd t/sampledata/var || exit $? ln -sf a b || exit $? ln -sf b c || exit $? ln -sf "$(pwd)/abs-symlink-target" abs-symlink || 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 + # exist. + touch rev/v$revision || exit $? ) || exit $? ;; - '--clean') - ( - cd t/sampledata || exit $? - # test -e is false for dangling symlinks. - if test -h b -o -e b; then rm b || exit $?; fi - if test -h c -o -e c; then rm c || exit $?; fi - if test -h abs-symlink -o -e abs-symlink; then - rm abs-symlink || exit $? - fi - ) + --clean) + clean + ;; + --revision) + echo "$revision" || exit $? ;; *) usage 1>&2; exit 1