]> arthur.barton.de Git - bup.git/commitdiff
Currently bup only indexes physical parent paths; adjust tests.
authorZoran Zaric <zz@zoranzaric.de>
Mon, 29 Jul 2013 17:23:10 +0000 (19:23 +0200)
committerRob Browning <rlb@defaultvalue.org>
Tue, 30 Jul 2013 22:27:11 +0000 (17:27 -0500)
Fix tests that fail on systems where components of the parent path are
symlinks (like /tmp on OS X).  i.e. if you run:

  bup index /x/y/z

bup might actually store

  /a/z...

if y is a symlink to a.  See index-cmd.py and index.reduce_paths().

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
[rlb@defaultvalue.org: handle test.sh fix differently; add realpath();
 adjust commit message.]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/t/tmetadata.py
t/lib.sh
t/test.sh

index 689bbba905b0616b84c4d65109d42c01896ad49a..471cb2f4c8d3b43deef45f2e4566b278af18b7f8 100644 (file)
@@ -1,7 +1,7 @@
 import glob, grp, pwd, stat, tempfile, subprocess
 import bup.helpers as helpers
 from bup import git, metadata, vfs
-from bup.helpers import clear_errors, detect_fakeroot, is_superuser
+from bup.helpers import clear_errors, detect_fakeroot, is_superuser, realpath
 from wvtest import *
 from bup.xstat import utime, lutime
 
@@ -131,7 +131,7 @@ def test_metadata_method():
         ex(bup_path, '-d', bup_dir, 'save', '-tvvn', 'test', data_path)
         git.check_repo_or_die(bup_dir)
         top = vfs.RefList(None)
-        n = top.lresolve('/test/latest' + data_path)
+        n = top.lresolve('/test/latest' + realpath(data_path))
         m = n.metadata()
         WVPASS(m.mtime == test_time2)
         WVPASS(len(n.subs()) == 2)
index a683bc3b19c1d450ece8ec8ea30469dc81dc86ec..e7e2ce8d71458d31e2771e5c7282ed0695d23d73 100644 (file)
--- a/t/lib.sh
+++ b/t/lib.sh
@@ -18,3 +18,13 @@ force-delete()
         fi
     done
 }
+
+realpath()
+(
+    set -e;
+    test "$#" -eq 1
+    script_home=$(cd "$(dirname $0)" && pwd)
+    echo "$1" | \
+        PYTHONPATH="${script_home}/../lib" python -c \
+        "import sys, bup.helpers; print bup.helpers.realpath(sys.stdin.readline())"
+)
index c0d95537a72abf2706aad72c85ee83f00b4953b4..3656689e0343944893ede400951fb84738d12684 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -673,16 +673,20 @@ WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
 WVSTART "save disjoint top-level directories"
 (
     set -e
-    top_dir="$(echo $(pwd) | awk -F "/" '{print $2}')"
-    if [ "$top_dir" == tmp ]; then
-        echo "(running from within /tmp; skipping test)"
+    # Resolve any symlinks involving the top top-level dirs.
+    real_pwd="$(realpath .)"
+    real_tmp="$(realpath /tmp/.)"
+    pwd_top="$(echo $real_pwd | awk -F "/" '{print $2}')"
+    tmp_top="$(echo $real_tmp | awk -F "/" '{print $2}')"
+    if [ "$pwd_top" = "$tmp_top" ]; then
+        echo "(running from within /$tmp_top; skipping test)"
         exit 0
     fi
     D=bupdata.tmp
     force-delete $D
     mkdir -p $D/x
     date > $D/x/1
-    tmpdir="$(mktemp -d /tmp/bup-test-XXXXXXX)"
+    tmpdir="$(mktemp -d $real_tmp/bup-test-XXXXXXX)"
     cleanup() { set -x; rm -r "${tmpdir}"; set +x; }
     trap cleanup EXIT
     date > "$tmpdir/2"
@@ -693,8 +697,10 @@ WVSTART "save disjoint top-level directories"
     WVPASS bup init
     WVPASS bup index -vu $(pwd)/$D/x "$tmpdir"
     WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir"
+
     # For now, assume that "ls -a" and "sort" use the same order.
-    WVPASSEQ "$(bup ls -a src/latest)" "$(echo -e "$top_dir/\ntmp/" | sort)"
+    WVPASSEQ "$(bup ls -a src/latest)" \
+        "$(echo -e "$pwd_top/\n$tmp_top/" | sort)"
 ) || WVFAIL
 
 WVSTART "clear-index"