__init__.py 3.21 KB
Newer Older
1 2 3
import glob, os, subprocess
# test_suite is provided by 'run_test_suite'
from test_suite import ERP5TypeTestSuite
Sebastien Robin's avatar
Sebastien Robin committed
4
import sys
5 6 7 8 9

class _ERP5(ERP5TypeTestSuite):
  realtime_output = False
  enabled_product_list = ('CMFActivity', 'CMFCategory', 'ERP5', 'ERP5Catalog',
                          'ERP5eGovSecurity', 'ERP5Form', 'ERP5Legacy',
10
                          'ERP5OOo', 'ERP5Security', 'ERP5SyncML', 'ERP5Type',
11
                          'ERP5VCS', 'ERP5Wizard', 'Formulator', 'ERP5Workflow',
12 13 14
                          'ERP5Configurator','HBTreeFolder2', 'MailTemplates', 
                          'PortalTransforms', 'TimerService', 'ZLDAPConnection', 
                          'ZLDAPMethods', 'ZMySQLDA', 'ZMySQLDDA', 'ZSQLCatalog')
15 16 17 18 19 20 21 22 23 24 25 26 27 28

  def enableProducts(self):
    product_set = set(self.enabled_product_list)
    try:
      dir_set = set(os.walk('Products').next()[1])
      for product in dir_set - product_set:
        os.unlink(os.path.join('Products', product))
      product_set -= dir_set
    except StopIteration:
      os.mkdir('Products')
    for product in product_set:
      os.symlink(os.path.join('..', 'products', product),
                 os.path.join('Products', product))

29
  def update(self):
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
    self.checkout('products', 'bt5')
    self.enableProducts()


class PERF(_ERP5):
  allow_restart = True

  def getTestList(self):
    return ('testPerformance',) * 3

  def update(self):
    self.checkout('products', 'bt5/erp5_base', 'bt5/erp5_ui_test')
    self.enableProducts()

class ERP5(_ERP5):
  mysql_db_count = 3

  def getTestList(self):
    test_list = []
49 50
    for test_path in glob.glob('%s/product/*/tests/test*.py' % sys.path[0]) + \
                 glob.glob('%s/bt5/*/TestTemplateItem/test*.py' % sys.path[0]):
51 52 53 54 55 56 57
      test_case = test_path.split(os.sep)[-1][:-3] # remove .py
      product = test_path.split(os.sep)[-3]
      # don't test 3rd party products
      if product in ('PortalTransforms', 'MailTemplates'):
        continue
      # skip some tests
      if test_case.startswith('testLive') or test_case.startswith('testVifib') \
58
         or test_case in ('testPerformance', 'testSimulationPerformance',
59
                          'testDmsWithFlare', # XXX(Seb), put it back ASAP
60
                          'testAccounting_l10n_fr_m9'):
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
        continue
      test_list.append(test_case)
    return test_list

  def run(self, test):
    if test in ('testConflictResolution', 'testInvalidationBug'):
      status_dict = self.runUnitTest('--save', test)
      if not status_dict['status_code']:
        status_dict = self.runUnitTest('--load', '--activity_node=2', test)
      return status_dict
    return super(ERP5, self).run(test)

class ERP5_simulation(_ERP5):

  def getTestList(self):
    p = subprocess.Popen(('grep', '-lr', '--include=test*.py',
                          '-e', '@newSimulationExpectedFailure',
                          '-e', 'erp5_report_new_simulation_failures',
                          'Products/ERP5/tests'),
                         stdout=subprocess.PIPE)
    return sorted(os.path.basename(x)[:-3]
                  for x in p.communicate()[0].splitlines())

  def runUnitTest(self, *args, **kw):
    return super(ERP5_simulation, self).runUnitTest(
      erp5_report_new_simulation_failures='1', *args, **kw)