[Zope-Checkins] SVN: Zope/trunk/ Made test.py follow symbolic links
(backport from Z3 test.py).
Stefan H. Holek
stefan at epy.co.at
Fri Aug 6 05:42:17 EDT 2004
Log message for revision 26933:
Made test.py follow symbolic links (backport from Z3 test.py).
Changed:
U Zope/trunk/doc/CHANGES.txt
U Zope/trunk/test.py
-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt 2004-08-05 23:47:56 UTC (rev 26932)
+++ Zope/trunk/doc/CHANGES.txt 2004-08-06 09:42:17 UTC (rev 26933)
@@ -26,6 +26,8 @@
Features added
+ - Made test.py follow symbolic links on POSIX systems.
+
- added utilities/reindex_catalog.py to perform ZCatalog maintenance
operations from the command line (through zopectl)
Modified: Zope/trunk/test.py
===================================================================
--- Zope/trunk/test.py 2004-08-05 23:47:56 UTC (rev 26932)
+++ Zope/trunk/test.py 2004-08-06 09:42:17 UTC (rev 26933)
@@ -471,10 +471,10 @@
global finder
finder = TestFileFinder(pathinit.libdir)
if test_dir:
- walkdir = os.path.realpath(os.path.join(pathinit.cwd, test_dir))
+ walkdir = os.path.abspath(os.path.join(pathinit.cwd, test_dir))
else:
walkdir = pathinit.libdir
- os.path.walk(walkdir, finder.visit, rx)
+ walk_with_symlinks(walkdir, finder.visit, rx)
return finder.files
def package_import(modname):
@@ -608,6 +608,24 @@
else:
raise
+def walk_with_symlinks(path, visit, arg):
+ """Like os.path.walk, but follows symlinks on POSIX systems.
+
+ This could theoretically result in an infinite loop, if you create symlink
+ cycles in your Zope sandbox, so don't do that.
+ """
+ try:
+ names = os.listdir(path)
+ except os.error:
+ return
+ visit(arg, path, names)
+ exceptions = (os.curdir, os.pardir)
+ for name in names:
+ if name not in exceptions:
+ name = os.path.join(path, name)
+ if os.path.isdir(name):
+ walk_with_symlinks(name, visit, arg)
+
def remove_stale_bytecode(arg, dirname, names):
names = map(os.path.normcase, names)
for name in names:
@@ -628,7 +646,7 @@
pathinit = PathInit(build, libdir)
if not keepStaleBytecode:
- os.path.walk(pathinit.home, remove_stale_bytecode, None)
+ walk_with_symlinks(pathinit.home, remove_stale_bytecode, None)
# Load configuration
if config_file:
More information about the Zope-Checkins
mailing list