Commit 4ee71a75 authored by Jérome Perrin's avatar Jérome Perrin

Add a --bt5_path argument to specify the path to business template directory.

Add support for NT platform. From Klaus Wölfel


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15720 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0322d57c
...@@ -295,6 +295,8 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -295,6 +295,8 @@ class ERP5TypeTestCase(PortalTestCase):
cfg.instancehome = os.environ['COPY_OF_INSTANCE_HOME'] cfg.instancehome = os.environ['COPY_OF_INSTANCE_HOME']
App.config.setConfiguration(cfg) App.config.setConfiguration(cfg)
INSTANCE_HOME = os.environ['INSTANCE_HOME'] INSTANCE_HOME = os.environ['INSTANCE_HOME']
bt5_path = os.environ.get('erp5_tests_bt5_path',
os.path.join(INSTANCE_HOME, 'bt5'))
template_list = self.getBusinessTemplateList() template_list = self.getBusinessTemplateList()
new_template_list = [] new_template_list = []
...@@ -305,7 +307,7 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -305,7 +307,7 @@ class ERP5TypeTestCase(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(INSTANCE_HOME, 'bt5', template) path = os.path.join(bt5_path, template)
if os.path.exists(path): if os.path.exists(path):
template = path template = path
else: else:
......
...@@ -4,6 +4,12 @@ import sys ...@@ -4,6 +4,12 @@ import sys
import getopt import getopt
import unittest import unittest
WIN = False
if os.name == 'nt':
import shutil
WIN = True
__doc__ = """%(program)s: unit test runner for the ERP5 Project __doc__ = """%(program)s: unit test runner for the ERP5 Project
usage: %(program)s [options] [UnitTest1[.TestClass1[.testMethod]] [UnitTest2]] usage: %(program)s [options] [UnitTest1[.TestClass1[.testMethod]] [UnitTest2]]
...@@ -18,6 +24,8 @@ Options: ...@@ -18,6 +24,8 @@ Options:
--data_fs_path=STRING Path to the original Data.fs to run tests on an --data_fs_path=STRING Path to the original Data.fs to run tests on an
existing environment. The Data.fs is opened read existing environment. The Data.fs is opened read
only only
--bt5_path Path to the Business Templates. Default is
INSTANCE_HOME/bt5.
--recreate_catalog=0 or 1 recreate the content of the sql catalog. Default --recreate_catalog=0 or 1 recreate the content of the sql catalog. Default
is to recreate, unless using --data_fs_path is to recreate, unless using --data_fs_path
--save add erp5 sites and business templates in Data.fs --save add erp5 sites and business templates in Data.fs
...@@ -66,13 +74,22 @@ def initializeInstanceHome(tests_framework_home, ...@@ -66,13 +74,22 @@ def initializeInstanceHome(tests_framework_home,
if not os.path.exists(dst): if not os.path.exists(dst):
if os.path.islink(dst): if os.path.islink(dst):
os.unlink(dst) os.unlink(dst)
os.symlink(src, dst) if WIN:
if d in ('Products', 'bt5', 'svn'):
os.mkdir(dst)
else:
shutil.copytree(src, dst)
else:
os.symlink(src, dst)
src = os.path.join(tests_framework_home, 'custom_zodb.py') src = os.path.join(tests_framework_home, 'custom_zodb.py')
dst = os.path.join(instance_home, 'custom_zodb.py') dst = os.path.join(instance_home, 'custom_zodb.py')
if not os.path.exists(dst): if not os.path.exists(dst):
if os.path.islink(dst): if os.path.islink(dst):
os.unlink(dst) os.unlink(dst)
os.symlink(src, dst) if WIN:
shutil.copy(src, dst)
else:
os.symlink(src, dst)
sys.path.append(os.path.join(zope_home, "bin")) sys.path.append(os.path.join(zope_home, "bin"))
import copyzopeskel import copyzopeskel
kw = { kw = {
...@@ -85,17 +102,26 @@ def initializeInstanceHome(tests_framework_home, ...@@ -85,17 +102,26 @@ def initializeInstanceHome(tests_framework_home,
copyzopeskel.copyskel(skelsrc, instance_home, None, None, **kw) copyzopeskel.copyskel(skelsrc, instance_home, None, None, **kw)
# site specific variables # site specific variables
# handle 64bit architecture
if os.path.isdir('/usr/lib64/zope/lib/python'): tests_framework_home = os.path.dirname(os.path.abspath(__file__))
# handle 64bit architecture and windows
if WIN:
erp5_home = os.path.sep.join(
tests_framework_home.split(os.path.sep)[:-4])
zope_home = os.path.join(erp5_home, 'Zope')
software_home = os.path.join(zope_home, 'lib', 'python')
elif os.path.isdir('/usr/lib64/zope/lib/python'):
software_home = '/usr/lib64/zope/lib/python' software_home = '/usr/lib64/zope/lib/python'
zope_home = '/usr/lib64/zope' zope_home = '/usr/lib64/zope'
else: else:
software_home = '/usr/lib/zope/lib/python' software_home = '/usr/lib/zope/lib/python'
zope_home = '/usr/lib/zope' zope_home = '/usr/lib/zope'
tests_framework_home = os.path.dirname(os.path.abspath(__file__)) # handle 'system global' instance and windows
# handle 'system global' instance if WIN:
if tests_framework_home.startswith('/usr/lib'): real_instance_home = os.path.join(erp5_home, 'ERP5Instance')
elif tests_framework_home.startswith('/usr/lib'):
real_instance_home = '/var/lib/zope' real_instance_home = '/var/lib/zope'
else: else:
real_instance_home = os.path.sep.join( real_instance_home = os.path.sep.join(
...@@ -143,6 +169,13 @@ def runUnitTestList(test_list) : ...@@ -143,6 +169,13 @@ def runUnitTestList(test_list) :
os.environ.setdefault('EVENT_LOG_SEVERITY', '-300') os.environ.setdefault('EVENT_LOG_SEVERITY', '-300')
execfile(os.path.join(tests_framework_home, 'framework.py')) execfile(os.path.join(tests_framework_home, 'framework.py'))
if WIN:
products_home = os.path.join(real_instance_home, 'Products')
import Products
Products.__path__.insert(0, products_home)
else:
products_home = os.path.join(instance_home, 'Products')
from Testing import ZopeTestCase from Testing import ZopeTestCase
...@@ -173,7 +206,6 @@ def runUnitTestList(test_list) : ...@@ -173,7 +206,6 @@ def runUnitTestList(test_list) :
os.chdir(tests_home) os.chdir(tests_home)
# allow unit tests of our Products to be reached. # allow unit tests of our Products to be reached.
products_home = os.path.join(instance_home, 'Products')
from glob import glob from glob import glob
product_test_list = glob(products_home + os.sep + '*' + os.sep + 'tests') product_test_list = glob(products_home + os.sep + '*' + os.sep + 'tests')
sys.path.extend(product_test_list) sys.path.extend(product_test_list)
...@@ -213,6 +245,7 @@ def main(): ...@@ -213,6 +245,7 @@ def main():
try: try:
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(sys.argv[1:],
"hpv", ["help", "verbose", "profile", "portal_id=", "data_fs_path=", "hpv", ["help", "verbose", "profile", "portal_id=", "data_fs_path=",
"bt5_path=",
"recreate_catalog=", "erp5_sql_connection_string=", "recreate_catalog=", "erp5_sql_connection_string=",
"cmf_activity_sql_connection_string=", "cmf_activity_sql_connection_string=",
"erp5_sql_deferred_connection_string=", "erp5_sql_deferred_connection_string=",
...@@ -224,8 +257,11 @@ def main(): ...@@ -224,8 +257,11 @@ def main():
usage(sys.stderr, msg) usage(sys.stderr, msg)
sys.exit(2) sys.exit(2)
os.environ["erp5_tests_recreate_catalog"] = "0" if WIN:
os.environ["erp5_tests_bt5_path"] = os.path.join(real_instance_home, 'bt5')
os.environ["erp5_tests_recreate_catalog"] = "0"
for opt, arg in opts: for opt, arg in opts:
if opt in ("-v", "--verbose"): if opt in ("-v", "--verbose"):
os.environ['VERBOSE'] = "1" os.environ['VERBOSE'] = "1"
...@@ -245,6 +281,8 @@ def main(): ...@@ -245,6 +281,8 @@ def main():
elif opt == '--data_fs_path': elif opt == '--data_fs_path':
os.environ["erp5_tests_data_fs_path"] = arg os.environ["erp5_tests_data_fs_path"] = arg
os.environ["erp5_tests_recreate_catalog"] = "1" os.environ["erp5_tests_recreate_catalog"] = "1"
elif opt == '--bt5_path':
os.environ["erp5_tests_bt5_path"] = arg
elif opt == '--recreate_catalog': elif opt == '--recreate_catalog':
os.environ["erp5_tests_recreate_catalog"] = arg os.environ["erp5_tests_recreate_catalog"] = arg
elif opt == "--erp5_sql_connection_string": elif opt == "--erp5_sql_connection_string":
......
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