[Erp5-report] r35115 leonardo - /erp5/trunk/products/ERP5Type/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 7 16:25:06 CEST 2010


Author: leonardo
Date: Fri May  7 16:25:02 2010
New Revision: 35115

URL: http://svn.erp5.org?rev=35115&view=rev
Log:
Allow functional tests to be run within the unit-test infrastructure with a single command

Modified:
    erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
    erp5/trunk/products/ERP5Type/tests/prepareFunctionalTest.py
    erp5/trunk/products/ERP5Type/tests/runFunctionalTest.py

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=35115&r1=35114&r2=35115&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] Fri May  7 16:25:02 2010
@@ -991,7 +991,7 @@
                 from Products import DeadlockDebugger
               except ImportError:
                 pass
-              self.startZServer()
+              self.serverhost, self.serverport = self.startZServer()
 
             self._updateConversionServerConfiguration()
             self._updateConnectionStrings()

Modified: erp5/trunk/products/ERP5Type/tests/prepareFunctionalTest.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/prepareFunctionalTest.py?rev=35115&r1=35114&r2=35115&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/prepareFunctionalTest.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/prepareFunctionalTest.py [utf8] Fri May  7 16:25:02 2010
@@ -32,10 +32,30 @@
 # usage: python runUnitTest.py --save [OPTION]... prepareFunctionalTest.py
 #
 
-import os
+import os, os.path
 import unittest
 
 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'
 
@@ -70,10 +90,22 @@
                 # 'erp5_payroll_ui_test',
                 )
 
-    def testInformation(self):
-        print MSG
-        import IPython.Shell
-        IPython.Shell.IPShellEmbed('')(local_ns=locals(), global_ns=globals())
+    def testFunctional(self):
+      # first of all, abort to get rid of the mysql participation inn this
+      # transaction
+      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():
     suite = unittest.TestSuite()

Modified: erp5/trunk/products/ERP5Type/tests/runFunctionalTest.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/runFunctionalTest.py?rev=35115&r1=35114&r2=35115&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/runFunctionalTest.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/runFunctionalTest.py [utf8] Fri May  7 16:25:02 2010
@@ -80,9 +80,11 @@
     program = os.path.basename(sys.argv[0])
     print >>stream, __doc__ % {"program": program}
 
-  def parseArgs(self):
+  def parseArgs(self, arguments=None):
+    if arguments is None:
+      arguments = sys.argv[:1]
     try:
-      opts, args = getopt.getopt(sys.argv[1:],
+      opts, args = getopt.getopt(arguments,
             "hsd", ["help", "stdout", "debug",
                    "email_to_address=", "host=", "port=", 
                    "portal_name=", "run_only=", "user=", 
@@ -278,6 +280,12 @@
     self.setPreference()
     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):
     result_uri = urllib2.urlopen('%s/portal_tests/TestTool_getResults' % self.portal_url).readline()
     print result_uri
@@ -293,9 +301,7 @@
     failures = failures_re.search(file_content).group(1)
     error_titles = [re.compile('\s+').sub(' ', x).strip()
                     for x in error_title_re.findall(file_content)]
-    # get SVN revision used
-    os.chdir('%s/Products/ERP5' % self.instance_home)
-    revision = pysvn.Client().info('.').revision.number
+    revision = self.getSvnRevision()
   
     subject = "%s r%s: Functional Tests, %s Passes, %s Failures" \
                 % (self.email_subject, revision, passes, failures)




More information about the Erp5-report mailing list