]> arthur.barton.de Git - bup.git/commitdiff
Create t/sampledata/var/ and version it
authorRob Browning <rlb@defaultvalue.org>
Sat, 21 Mar 2015 19:57:18 +0000 (14:57 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 28 Mar 2015 15:34:51 +0000 (10:34 -0500)
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 <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Makefile
lib/bup/t/tindex.py
t/configure-sampledata

index ffb46273dc02bf404f441d32eefce8e70fc81852..5bc3bcc8c7ec5596659813c834012bc0b8780153 100644 (file)
--- 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
index 3ec4939e5a4b415a039d97284f2b295d5fd79ebf..106d0feac9bf8b90e44f4ae3fefa5f7004a0de60 100644 (file)
@@ -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
index d88472765ef99b2559c8aaeeb3910d0b55255469..c95d936fc38251794de4489982fc945fb1ebfb1f 100755 (executable)
@@ -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