Commit 857e647a authored by Rafael Monnerat's avatar Rafael Monnerat

Extend the support of --bt5-path= argument to support multiple values like:

 --bt5-path=bt5/folder/0,bt5/folder/3,another/bt5

Values split by Comma format was choose because it is already used by run_only and update_only. 



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33196 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 68cf9524
...@@ -388,7 +388,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -388,7 +388,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
def _getBTPathAndIdList(self, template_list): def _getBTPathAndIdList(self, template_list):
INSTANCE_HOME = os.environ['INSTANCE_HOME'] INSTANCE_HOME = os.environ['INSTANCE_HOME']
bt5_path = os.environ.get('erp5_tests_bt5_path', erp5_tests_bt5_path = os.environ.get('erp5_tests_bt5_path',
os.path.join(INSTANCE_HOME, 'bt5')) os.path.join(INSTANCE_HOME, 'bt5'))
erp5_product_path = os.path.dirname(Products.ERP5.__file__) erp5_product_path = os.path.dirname(Products.ERP5.__file__)
bootstrap_path = os.environ.get('erp5_tests_bootstrap_path', bootstrap_path = os.environ.get('erp5_tests_bootstrap_path',
...@@ -401,30 +401,36 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -401,30 +401,36 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
file, headers = urlretrieve(template) file, headers = urlretrieve(template)
except IOError : except IOError :
# First, try the bt5 directory itself. # First, try the bt5 directory itself.
path = os.path.join(bt5_path, template) original_template = template
alternate_path = os.path.join(bootstrap_path, template) for bt5_path in erp5_tests_bt5_path.split(','):
if os.path.exists(path): template = original_template
template = path path = os.path.join(bt5_path, template)
elif os.path.exists(alternate_path): alternate_path = os.path.join(bootstrap_path, template)
template = alternate_path
else:
path = '%s.bt5' % path
if os.path.exists(path): if os.path.exists(path):
template = path template = path
break
elif os.path.exists(alternate_path):
template = alternate_path
break
else: else:
# Otherwise, look at sub-directories. path = '%s.bt5' % path
# This is for backward-compatibility. if os.path.exists(path):
path = os.path.join(INSTANCE_HOME, 'bt5', '*', template) template = path
template_list = glob(path) break
if len(template_list) == 0:
template_list = glob('%s.bt5' % path)
if len(template_list) and template_list[0]:
template = template_list[0]
else: else:
# The last resort is current directory. # Otherwise, look at sub-directories.
template = '%s' % id # This is for backward-compatibility.
if not os.path.exists(template): path = os.path.join(INSTANCE_HOME, 'bt5', '*', template)
template = '%s.bt5' % id template_list = glob(path)
if len(template_list) == 0:
template_list = glob('%s.bt5' % path)
if len(template_list) and template_list[0]:
template = template_list[0]
else:
# The last resort is current directory.
template = '%s' % id
if not os.path.exists(template):
template = '%s.bt5' % id
else: else:
template = '%s' % template template = '%s' % template
if not os.path.exists(template): if not os.path.exists(template):
......
...@@ -369,12 +369,17 @@ def runUnitTestList(test_list, verbosity=1, debug=0): ...@@ -369,12 +369,17 @@ def runUnitTestList(test_list, verbosity=1, debug=0):
from glob import glob from glob import glob
product_test_list = glob(os.path.join(products_home, '*', 'tests')) product_test_list = glob(os.path.join(products_home, '*', 'tests'))
sys.path.extend(product_test_list) sys.path.extend(product_test_list)
bt5_path = os.environ.get('erp5_tests_bt5_path', erp5_tests_bt5_path = os.environ.get('erp5_tests_bt5_path',
os.path.join(instance_home, 'bt5')) os.path.join(instance_home, 'bt5'))
bt5_test_list = glob(os.path.join(bt5_path, '*', 'TestTemplateItem')) bt5_path_list = erp5_tests_bt5_path.split(",")
bt5_test_list = []
project_bt5_test_list = []
for bt5_path in bt5_path_list:
bt5_test_list.extend(glob(os.path.join(bt5_path,'*','TestTemplateItem')))
# also suport instance_home/bt5/project_bt5/*
project_bt5_test_list.extend(glob(os.path.join(bt5_path, '*', '*',
'TestTemplateItem')))
sys.path.extend(bt5_test_list) sys.path.extend(bt5_test_list)
# also suport instance_home/bt5/project_bt5/*
project_bt5_test_list = glob(os.path.join(bt5_path, '*', '*', 'TestTemplateItem'))
sys.path.extend(project_bt5_test_list) sys.path.extend(project_bt5_test_list)
sys.path.extend((real_tests_home, tests_home)) sys.path.extend((real_tests_home, tests_home))
......
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