[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] run-repos-tests.py fix for Windows

From: D.J. Heap <dj_at_shadyvale.net>
Date: 2004-03-13 02:05:15 CET

Log:
Use the safe_rmtree method (from the cmdline test suite) of removing old
repositories since they now have read-only files which Windows will not
delete.

* subversion/tests/python-libs/exectest.py
   (safe_rmtree, chmod_tree): New methods copied from
   subversion/tests/clients/cmdline/svntest/main.py for safely
   removing file trees.
   (run_tests): Use the new safe_rmtree.

Index: subversion/tests/python-libs/exectest.py
===================================================================
--- subversion/tests/python-libs/exectest.py (revision 9026)
+++ subversion/tests/python-libs/exectest.py (working copy)
@@ -2,7 +2,7 @@
 #
 # exectest.py: run a set of executable tests
 
-import os, sys, shutil
+import os, sys, shutil, time, stat
 __all__ = ['run_tests']
 
 # Platform-specifics
@@ -22,7 +22,7 @@
   for name in os.listdir('.'):
     if name[:10] != 'test-repo-':
       continue
- shutil.rmtree(name)
+ safe_rmtree(name, 1)
 
   # Run the tests
   errors = 0;
@@ -35,5 +35,37 @@
       errors = 1
   return errors
 
+# Chmod recursively on a whole subtree
+def chmod_tree(path, mode, mask):
+ def visit(arg, dirname, names):
+ mode, mask = arg
+ for name in names:
+ fullname = os.path.join(dirname, name)
+ if not os.path.islink(fullname):
+ new_mode = (os.stat(fullname)[stat.ST_MODE] & ~mask) | mode
+ os.chmod(fullname, new_mode)
+ os.path.walk(path, visit, (mode, mask))
 
+# For clearing away working copies
+def safe_rmtree(dirname, retry=0):
+ "Remove the tree at DIRNAME, making it writable first"
+ def rmtree(dirname):
+ chmod_tree(dirname, 0666, 0666)
+ shutil.rmtree(dirname)
+
+ if not os.path.exists(dirname):
+ return
+
+ if retry:
+ for delay in (0.5, 1, 2, 4):
+ try:
+ rmtree(dirname)
+ break
+ except:
+ time.sleep(delay)
+ else:
+ rmtree(dirname)
+ else:
+ rmtree(dirname)
+
 ### End of file.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Mar 13 02:05:53 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.