]> arthur.barton.de Git - bup.git/commitdiff
tgit.py: provoke ENOTDIR rather than EACCES in test_check_repo_or_die().
authorRob Browning <rlb@defaultvalue.org>
Mon, 21 Mar 2011 01:35:53 +0000 (20:35 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Mon, 21 Mar 2011 08:34:30 +0000 (01:34 -0700)
Replace the objects/pack directory with an empty file to provoke an
ENOTDIR error from stat('objects/pack/.').

Previously the code changed the permissions of the test directory to
0000 in order to provoke an error other than ENOENT (i.e. EACCES), but
that doesn't work when the tests are run as root or fakeroot.

(As Gabriel Filion pointed out, the chmod of the testdir is no
longer necessary, so I removed it and squashed that into this patch.
-- apenwarr)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
Makefile
lib/bup/t/tgit.py

index 5a317a6c974eec075e9e5a35cad43566204bfa59..daa5a1d7aac1b6f6263415fdd790a7960e0e1d5b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -148,7 +148,6 @@ clean: Documentation/clean
                bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
                out[12] out2[tc] tags[12] tags2[tc] \
                testfs.img lib/bup/t/testfs.img
-       [ -d lib/bup/t/pybuptest.tmp ] && chmod u+rwx lib/bup/t/pybuptest.tmp || true
        rm -rf *.tmp t/*.tmp lib/*/*/*.tmp build lib/bup/build
        if test -e testfs; then rmdir testfs; fi
        if test -e lib/bup/t/testfs; then rmdir lib/bup/t/testfs; fi
index 0c2db1770edf0262bfde0ba1461eb89b72aec610..b564736879756bff7c5e7cdabced646a7e23683a 100644 (file)
@@ -147,15 +147,16 @@ def test_check_repo_or_die():
     git.check_repo_or_die()
     WVPASS('check_repo_or_die')  # if we reach this point the call above passed
 
-    mode = os.stat('pybuptest.tmp').st_mode
-    os.chmod('pybuptest.tmp', 0000)
+    os.rename('pybuptest.tmp/objects/pack', 'pybuptest.tmp/objects/pack.tmp')
+    open('pybuptest.tmp/objects/pack', 'w').close()
     try:
         git.check_repo_or_die()
     except SystemExit, e:
         WVPASSEQ(e.code, 14)
     else:
         WVFAIL()
-    os.chmod('pybuptest.tmp', mode)
+    os.unlink('pybuptest.tmp/objects/pack')
+    os.rename('pybuptest.tmp/objects/pack.tmp', 'pybuptest.tmp/objects/pack')
 
     try:
         git.check_repo_or_die('nonexistantbup.tmp')