diff --git a/product/ERP5/bin/run_test_suite b/product/ERP5/bin/run_test_suite index be81b8b364cf0963421c04fc7b991133438b5abb..0c5d9b09ee7a45dd85c32f16929a8112de675215 100755 --- a/product/ERP5/bin/run_test_suite +++ b/product/ERP5/bin/run_test_suite @@ -347,6 +347,29 @@ for var in SubprocessError, TestSuite, ERP5TypeTestSuite: setattr(module, var.__name__, var) +class DummyTaskDistributionTool(object): + + def __init__(self): + self.lock = threading.Lock() + + def createTestResult(self, name, revision, test_name_list, allow_restart): + self.test_name_list = list(test_name_list) + return None, revision + + def startUnitTest(self, test_result_path, exclude_list=()): + self.lock.acquire() + try: + for i, test in enumerate(self.test_name_list): + if test not in exclude_list: + del self.test_name_list[i] + return None, test + finally: + self.lock.release() + + def stopUnitTest(self, test_path, status_dict): + pass + + def safeRpcCall(function, *args): retry = 64 while True: @@ -400,7 +423,8 @@ def main(): def makeSuite(revision=None): updater = Updater(revision) - updater.checkout('tests') + if portal_url: + updater.checkout('tests') for k in sys.modules.keys(): if k == 'tests' or k.startswith('tests.'): del sys.modules[k] @@ -416,15 +440,19 @@ def main(): suite = suite_class(revision=updater.revision, max_instance_count=max_instance_count, mysql_db_list=db_list[:suite_class.mysql_db_count]) - suite.update() + if portal_url: + suite.update() return suite portal_url = options.master - if portal_url[-1] != '/': - portal_url += '/' - portal = xmlrpclib.ServerProxy(portal_url, allow_none=1) - master = portal.portal_task_distribution - assert master.getProtocolRevision() == 1 + if portal_url: + if portal_url[-1] != '/': + portal_url += '/' + portal = xmlrpclib.ServerProxy(portal_url, allow_none=1) + master = portal.portal_task_distribution + assert master.getProtocolRevision() == 1 + else: + master = DummyTaskDistributionTool() suite = makeSuite() revision = suite.getRevision() @@ -432,9 +460,10 @@ def main(): name, revision, suite.getTestList(), suite.allow_restart) if test_result: test_result_path, test_revision = test_result - url_parts = list(urlparse.urlparse(portal_url + test_result_path)) - url_parts[1] = url_parts[1].split('@')[-1] - print 'ERP5_TEST_URL %s OK' % urlparse.urlunparse(url_parts) # for buildbot + if portal_url: # for buildbot + url_parts = list(urlparse.urlparse(portal_url + test_result_path)) + url_parts[1] = url_parts[1].split('@')[-1] + print 'ERP5_TEST_URL %s OK' % urlparse.urlunparse(url_parts) while suite.acquire(): test = safeRpcCall(master.startUnitTest, test_result_path, suite.running.keys())