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

Now also scans instancehome for stale bytecode.

parent eb938746
...@@ -87,7 +87,7 @@ named .testinfo, it will not be searched for tests. Really.) ...@@ -87,7 +87,7 @@ named .testinfo, it will not be searched for tests. Really.)
can be specified by using "-G OPTION1 -G OPTION2." can be specified by using "-G OPTION1 -G OPTION2."
--import-testing --import-testing
Import the Testing module to setup the test ZODB. Useful for running Import the Testing package to setup the test ZODB. Useful for running
tests that forgot to "import Testing". tests that forgot to "import Testing".
--libdir test_root --libdir test_root
...@@ -371,7 +371,7 @@ class PathInit: ...@@ -371,7 +371,7 @@ class PathInit:
self.libdir = "lib/python" self.libdir = "lib/python"
# Hack sys.path # Hack sys.path
self.home = os.path.dirname(os.path.realpath(sys.argv[0])) self.home = os.path.dirname(os.path.realpath(sys.argv[0]))
# test.py lives in bin directory when installed ... # test.py lives in $ZOPE_HOME/bin when installed ...
dir, file = os.path.split(self.home) dir, file = os.path.split(self.home)
if file == 'bin': self.home = dir if file == 'bin': self.home = dir
sys.path.insert(0, os.path.join(self.home, self.libdir)) sys.path.insert(0, os.path.join(self.home, self.libdir))
...@@ -633,8 +633,14 @@ def remove_stale_bytecode(arg, dirname, names): ...@@ -633,8 +633,14 @@ def remove_stale_bytecode(arg, dirname, names):
srcname = name[:-1] srcname = name[:-1]
if srcname not in names: if srcname not in names:
fullname = os.path.join(dirname, name) fullname = os.path.join(dirname, name)
print "Removing stale bytecode file", fullname print "Removing stale bytecode file", fullname,
os.unlink(fullname) try:
os.unlink(fullname)
except (OSError, IOError), e:
print ' --> %s (errno %d)' % (e.strerror, e.errno)
else:
print
def main(module_filter, test_filter, libdir): def main(module_filter, test_filter, libdir):
global pathinit global pathinit
...@@ -655,7 +661,15 @@ def main(module_filter, test_filter, libdir): ...@@ -655,7 +661,15 @@ def main(module_filter, test_filter, libdir):
import Zope import Zope
Zope.configure(config_file) Zope.configure(config_file)
# Import Testing module to setup the test ZODB if not keepStaleBytecode:
from App.config import getConfiguration
softwarehome = os.path.realpath(getConfiguration().softwarehome)
instancehome = os.path.realpath(getConfiguration().instancehome)
softwarehome = os.path.normcase(softwarehome)
if not softwarehome.startswith(os.path.normcase(instancehome)):
walk_with_symlinks(instancehome, remove_stale_bytecode, None)
# Import Testing package to setup the test ZODB
if import_testing: if import_testing:
import Testing import Testing
......
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