From 8569c50ee370aaf8b0fecfc8aa84d8cb7240493b Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Mon, 31 Jan 2011 14:19:50 +0000 Subject: [PATCH] run_test_suite: add dumb offline mode for testing purpose git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42828 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/bin/run_test_suite | 49 ++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/product/ERP5/bin/run_test_suite b/product/ERP5/bin/run_test_suite index be81b8b364..0c5d9b09ee 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()) -- 2.30.9