Commit eb938746 authored by Stefan H. Holek's avatar Stefan H. Holek

Made test.py follow symbolic links (backport from Z3 test.py).

parent 1b50a347
...@@ -26,6 +26,8 @@ Zope Changes ...@@ -26,6 +26,8 @@ Zope Changes
Features added Features added
- Made test.py follow symbolic links on POSIX systems.
- added utilities/reindex_catalog.py to perform ZCatalog maintenance - added utilities/reindex_catalog.py to perform ZCatalog maintenance
operations from the command line (through zopectl) operations from the command line (through zopectl)
......
...@@ -471,10 +471,10 @@ def find_tests(rx): ...@@ -471,10 +471,10 @@ def find_tests(rx):
global finder global finder
finder = TestFileFinder(pathinit.libdir) finder = TestFileFinder(pathinit.libdir)
if test_dir: 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: else:
walkdir = pathinit.libdir walkdir = pathinit.libdir
os.path.walk(walkdir, finder.visit, rx) walk_with_symlinks(walkdir, finder.visit, rx)
return finder.files return finder.files
def package_import(modname): def package_import(modname):
...@@ -608,6 +608,24 @@ def runner(files, test_filter, debug): ...@@ -608,6 +608,24 @@ def runner(files, test_filter, debug):
else: else:
raise 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): def remove_stale_bytecode(arg, dirname, names):
names = map(os.path.normcase, names) names = map(os.path.normcase, names)
for name in names: for name in names:
...@@ -628,7 +646,7 @@ def main(module_filter, test_filter, libdir): ...@@ -628,7 +646,7 @@ def main(module_filter, test_filter, libdir):
pathinit = PathInit(build, libdir) pathinit = PathInit(build, libdir)
if not keepStaleBytecode: if not keepStaleBytecode:
os.path.walk(pathinit.home, remove_stale_bytecode, None) walk_with_symlinks(pathinit.home, remove_stale_bytecode, None)
# Load configuration # Load configuration
if config_file: if config_file:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment