Allow functional tests to be run within the unit-test infrastructure with a single command

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35115 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 78bf0be3
...@@ -991,7 +991,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -991,7 +991,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
from Products import DeadlockDebugger from Products import DeadlockDebugger
except ImportError: except ImportError:
pass pass
self.startZServer() self.serverhost, self.serverport = self.startZServer()
self._updateConversionServerConfiguration() self._updateConversionServerConfiguration()
self._updateConnectionStrings() self._updateConnectionStrings()
......
...@@ -32,11 +32,31 @@ ...@@ -32,11 +32,31 @@
# usage: python runUnitTest.py --save [OPTION]... prepareFunctionalTest.py # usage: python runUnitTest.py --save [OPTION]... prepareFunctionalTest.py
# #
import os import os, os.path
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.runFunctionalTest import (
FunctionalTestRunner as FunctionalTestRunnerBase
)
class FunctionalTestRunner(FunctionalTestRunnerBase):
def __init__(self, host, port):
FunctionalTestRunnerBase.__init__(self, os.environ['INSTANCE_HOME'])
# local overrides
self.host = host
self.port = port
def getSvnRevision(self):
# we should get the revision of a business template, but this is good
# enough for now.
import pysvn
revision = pysvn.Client().info(os.path.dirname(__file__)).revision.number
return revision
os.environ['erp5_tests_portal_id'] = 'erp5_portal' os.environ['erp5_tests_portal_id'] = 'erp5_portal'
MSG = ''' MSG = '''
...@@ -70,10 +90,22 @@ class TestZelenium(ERP5TypeTestCase): ...@@ -70,10 +90,22 @@ class TestZelenium(ERP5TypeTestCase):
# 'erp5_payroll_ui_test', # 'erp5_payroll_ui_test',
) )
def testInformation(self): def testFunctional(self):
print MSG # first of all, abort to get rid of the mysql participation inn this
import IPython.Shell # transaction
IPython.Shell.IPShellEmbed('')(local_ns=locals(), global_ns=globals()) self.portal._p_jar.sync()
self.runner = FunctionalTestRunner(self.serverhost, self.serverport)
# XXX weak parsing of arguments, avoid spaces in argument values:
runner_arguments = os.environ.get('erp5_functional_test_arguments',
'').split()
self.runner.parseArgs(runner_arguments)
self.logMessage('starting functional test runner with arguments: %s' %
runner_arguments)
self.runner.main()
self.runner.sendResult()
#print MSG
#import IPython.Shell
#IPython.Shell.IPShellEmbed('')(local_ns=locals(), global_ns=globals())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -80,9 +80,11 @@ class FunctionalTestRunner: ...@@ -80,9 +80,11 @@ class FunctionalTestRunner:
program = os.path.basename(sys.argv[0]) program = os.path.basename(sys.argv[0])
print >>stream, __doc__ % {"program": program} print >>stream, __doc__ % {"program": program}
def parseArgs(self): def parseArgs(self, arguments=None):
if arguments is None:
arguments = sys.argv[:1]
try: try:
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(arguments,
"hsd", ["help", "stdout", "debug", "hsd", ["help", "stdout", "debug",
"email_to_address=", "host=", "port=", "email_to_address=", "host=", "port=",
"portal_name=", "run_only=", "user=", "portal_name=", "run_only=", "user=",
...@@ -278,6 +280,12 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \ ...@@ -278,6 +280,12 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \
self.setPreference() self.setPreference()
self.unsubscribeFromTimerService() self.unsubscribeFromTimerService()
def getSvnRevision(self):
# get SVN revision used
os.chdir('%s/Products/ERP5' % self.instance_home)
revision = pysvn.Client().info('.').revision.number
return revision
def sendResult(self): def sendResult(self):
result_uri = urllib2.urlopen('%s/portal_tests/TestTool_getResults' % self.portal_url).readline() result_uri = urllib2.urlopen('%s/portal_tests/TestTool_getResults' % self.portal_url).readline()
print result_uri print result_uri
...@@ -293,9 +301,7 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \ ...@@ -293,9 +301,7 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \
failures = failures_re.search(file_content).group(1) failures = failures_re.search(file_content).group(1)
error_titles = [re.compile('\s+').sub(' ', x).strip() error_titles = [re.compile('\s+').sub(' ', x).strip()
for x in error_title_re.findall(file_content)] for x in error_title_re.findall(file_content)]
# get SVN revision used revision = self.getSvnRevision()
os.chdir('%s/Products/ERP5' % self.instance_home)
revision = pysvn.Client().info('.').revision.number
subject = "%s r%s: Functional Tests, %s Passes, %s Failures" \ subject = "%s r%s: Functional Tests, %s Passes, %s Failures" \
% (self.email_subject, revision, passes, failures) % (self.email_subject, revision, passes, failures)
......
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