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):
def _getBTPathAndIdList(self, template_list):
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'))
erp5_product_path = os.path.dirname(Products.ERP5.__file__)
bootstrap_path = os.environ.get('erp5_tests_bootstrap_path',
......@@ -401,30 +401,36 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
file, headers = urlretrieve(template)
except IOError :
# First, try the bt5 directory itself.
path = os.path.join(bt5_path, template)
alternate_path = os.path.join(bootstrap_path, template)
if os.path.exists(path):
template = path
elif os.path.exists(alternate_path):
template = alternate_path
else:
path = '%s.bt5' % path
original_template = template
for bt5_path in erp5_tests_bt5_path.split(','):
template = original_template
path = os.path.join(bt5_path, template)
alternate_path = os.path.join(bootstrap_path, template)
if os.path.exists(path):
template = path
break
elif os.path.exists(alternate_path):
template = alternate_path
break
else:
# Otherwise, look at sub-directories.
# This is for backward-compatibility.
path = os.path.join(INSTANCE_HOME, 'bt5', '*', template)
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]
path = '%s.bt5' % path
if os.path.exists(path):
template = path
break
else:
# The last resort is current directory.
template = '%s' % id
if not os.path.exists(template):
template = '%s.bt5' % id
# Otherwise, look at sub-directories.
# This is for backward-compatibility.
path = os.path.join(INSTANCE_HOME, 'bt5', '*', template)
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:
template = '%s' % template
if not os.path.exists(template):
......
......@@ -369,12 +369,17 @@ def runUnitTestList(test_list, verbosity=1, debug=0):
from glob import glob
product_test_list = glob(os.path.join(products_home, '*', 'tests'))
sys.path.extend(product_test_list)
bt5_path = os.environ.get('erp5_tests_bt5_path',
os.path.join(instance_home, 'bt5'))
bt5_test_list = glob(os.path.join(bt5_path, '*', 'TestTemplateItem'))
erp5_tests_bt5_path = os.environ.get('erp5_tests_bt5_path',
os.path.join(instance_home, 'bt5'))
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)
# 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((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