From 9e36298cf02a2a0fba043cdb81888b03b83f155e Mon Sep 17 00:00:00 2001 From: "PAP(OpenERP)" <> Date: Fri, 30 Apr 2010 19:52:50 +0530 Subject: [PATCH] Added commmand line arguments to make yml test easier bzr revid: hda@tinyerp.com-20100430142250-ieb6mzx59wyvl3u9 --- bin/addons/__init__.py | 18 ++++++++++++++---- bin/tools/config.py | 18 +++++++++++++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index b1b140159c1..02803de0d75 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -640,10 +640,20 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs): def load_test(cr, module_name, id_map, mode): cr.commit() - try: - _load_data(cr, module_name, id_map, mode, 'test') - finally: - cr.rollback() + if not tools.config.options['test-disable']: + try: + _load_data(cr, module_name, id_map, mode, 'test') + except Exception, e: + if tools.config.options['test-continue']: + logger.notifyChannel('ERROR', netsvc.LOG_TEST, str(e)) + pass + else: + raise Exception + finally: + if tools.config.options['test-rollback']: + cr.rollback() + else: + cr.commit() def _load_data(cr, module_name, id_map, mode, kind): noupdate = (kind == 'demo') diff --git a/bin/tools/config.py b/bin/tools/config.py index 8f1f1ca55ea..a92948b8af0 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -82,6 +82,9 @@ class configmanager(object): 'login_message': False, 'list_db' : True, 'timezone' : False, # to override the default TZ + 'test-disable' : False, + 'test-rollback' : True, + 'test-continue' : False } self.misc = {} @@ -134,7 +137,17 @@ class configmanager(object): default="server.pkey", help="specify the private key file for the SSL connection") parser.add_option_group(group) - + + # Testing Group + group = optparse.OptionGroup(parser, "Testing Configuration") + group.add_option("--test-disable", action="store_true", dest="test_disable", + default=False, help="Disable loading test files.") + group.add_option("--test-no-rollback", action="store_false", dest="test_rollback", + default=True, help="Don't rollback after running test.") + group.add_option("--test-continue", action="store_true", dest="test_continue", + default=False, help="Display exception but then test should continue.") + parser.add_option_group(group) + # Logging Group group = optparse.OptionGroup(parser, "Logging Configuration") group.add_option("--logfile", dest="logfile", help="file where the server log will be stored") @@ -274,6 +287,9 @@ class configmanager(object): self.options['init'] = opt.init and dict.fromkeys(opt.init.split(','), 1) or {} self.options["demo"] = not opt.without_demo and self.options['init'] or {} + self.options["test-disable"] = opt.test_disable + self.options["test-rollback"] = opt.test_rollback + self.options["test-continue"] = opt.test_continue self.options['update'] = opt.update and dict.fromkeys(opt.update.split(','), 1) or {} self.options['translate_modules'] = opt.translate_modules and map(lambda m: m.strip(), opt.translate_modules.split(',')) or ['all']