Commit 8817c9ec authored by Jérome Perrin's avatar Jérome Perrin

runUnitTest: new --log_directory option

Log files will be created in this directory.
parent 8fb94415
...@@ -149,8 +149,8 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase): ...@@ -149,8 +149,8 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
"""Start HTTP ZServer in background""" """Start HTTP ZServer in background"""
utils = ZopeTestCase.utils utils = ZopeTestCase.utils
if utils._Z2HOST is None: if utils._Z2HOST is None:
from Products.ERP5Type.tests.runUnitTest import tests_home from Products.ERP5Type.tests.runUnitTest import log_directory
log = os.path.join(tests_home, "Z2.log") log = os.path.join(log_directory, "Z2.log")
message = "Running %s server at %s:%s\n" message = "Running %s server at %s:%s\n"
if int(os.environ.get('erp5_wsgi', 0)): if int(os.environ.get('erp5_wsgi', 0)):
from Products.ERP5.bin.zopewsgi import app_wrapper, createServer from Products.ERP5.bin.zopewsgi import app_wrapper, createServer
......
...@@ -158,6 +158,7 @@ Options: ...@@ -158,6 +158,7 @@ Options:
--sys_path=path,path Comma-separated list of paths which will be used to --sys_path=path,path Comma-separated list of paths which will be used to
extend sys.path extend sys.path
--instance_home=PATH Create/use test instance in given path --instance_home=PATH Create/use test instance in given path
--log_directory=PATH Create log files in given path
When no unit test is specified, only activities are processed. When no unit test is specified, only activities are processed.
""" """
...@@ -486,7 +487,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -486,7 +487,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
_print("conflicting options: --zeo_client and --zeo_server") _print("conflicting options: --zeo_client and --zeo_server")
sys.exit(1) sys.exit(1)
instance_home = os.environ['INSTANCE_HOME'] instance_home = os.environ['INSTANCE_HOME']
os.environ.setdefault('EVENT_LOG_FILE', os.path.join(tests_home, 'zLOG.log')) os.environ.setdefault('EVENT_LOG_FILE', os.path.join(log_directory, 'zLOG.log'))
os.environ.setdefault('EVENT_LOG_SEVERITY', '-300') os.environ.setdefault('EVENT_LOG_SEVERITY', '-300')
# For numpy parallel-primitives such as numpy.dot() that is used in # For numpy parallel-primitives such as numpy.dot() that is used in
# testReceiptRecognition for example. # testReceiptRecognition for example.
...@@ -742,6 +743,7 @@ def main(argument_list=None): ...@@ -742,6 +743,7 @@ def main(argument_list=None):
"products_path=", "products_path=",
"sys_path=", "sys_path=",
"instance_home=", "instance_home=",
"log_directory="
]) ])
except getopt.GetoptError, msg: except getopt.GetoptError, msg:
usage(sys.stderr, msg) usage(sys.stderr, msg)
...@@ -752,6 +754,7 @@ def main(argument_list=None): ...@@ -752,6 +754,7 @@ def main(argument_list=None):
debug = 0 debug = 0
run_only = None run_only = None
instance_home = os.path.join(real_instance_home, 'unit_test') instance_home = os.path.join(real_instance_home, 'unit_test')
_log_directory = instance_home
bt5_path_list = [] bt5_path_list = []
...@@ -860,6 +863,8 @@ def main(argument_list=None): ...@@ -860,6 +863,8 @@ def main(argument_list=None):
sys.path.extend(arg.split(',')) sys.path.extend(arg.split(','))
elif opt == "--instance_home": elif opt == "--instance_home":
instance_home = os.path.abspath(arg) instance_home = os.path.abspath(arg)
elif opt == "--log_directory":
_log_directory = os.path.abspath(arg)
bt5_path_list += filter(None, bt5_path_list += filter(None,
os.environ.get("erp5_tests_bt5_path", "").split(',')) os.environ.get("erp5_tests_bt5_path", "").split(','))
...@@ -878,6 +883,8 @@ def main(argument_list=None): ...@@ -878,6 +883,8 @@ def main(argument_list=None):
initializeInstanceHome(tests_framework_home, initializeInstanceHome(tests_framework_home,
real_instance_home, real_instance_home,
instance_home) instance_home)
global log_directory
log_directory = _log_directory or test_home
result = runUnitTestList(test_list=args, result = runUnitTestList(test_list=args,
verbosity=verbosity, verbosity=verbosity,
......
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