From d13015dfb55979e11a0df83f35f48886a43ad260 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 11 Apr 2013 19:09:50 +0200 Subject: [PATCH] Fix tests with Travis. --- .travis.yml | 2 +- scripts/supybot | 1 + scripts/supybot-test | 5 +++++ src/commands.py | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d8c66e67e..9b9eed175 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,5 @@ install: script: - echo $TRAVIS_PYTHON_VERSION - python setup.py install - - cd py3k/; supybot-test test --plugins-dir=plugins/ --exclude=plugins/PluginDownloader --exclude=plugins/ShrinkUrl + - cd py3k/; supybot-test test --plugins-dir=plugins/ --exclude=plugins/PluginDownloader --exclude=plugins/ShrinkUrl --disable-multiprocessing - cat test-logs/messages.log diff --git a/scripts/supybot b/scripts/supybot index d1820480f..aabd7351f 100644 --- a/scripts/supybot +++ b/scripts/supybot @@ -305,6 +305,7 @@ if __name__ == '__main__': sys.exit(-1) conf.allowDefaultOwner = options.allowDefaultOwner + conf.disableMultiprocessing = False if not os.path.exists(conf.supybot.directories.log()): os.mkdir(conf.supybot.directories.log()) diff --git a/scripts/supybot-test b/scripts/supybot-test index 52b4ad426..e1979a776 100644 --- a/scripts/supybot-test +++ b/scripts/supybot-test @@ -146,8 +146,13 @@ if __name__ == '__main__': action='append', dest='excludePlugins', default=[], help='List of plugins you do not want --plugins-dir ' 'to include.') + parser.add_option('', '--disable-multiprocessing', action='store_true', + dest='disableMultiprocessing', + help='Disables multiprocessing stuff.') (options, args) = parser.parse_args() + conf.disableMultiprocessing = options.disableMultiprocessing + # This must go before checking for args, of course. for pluginDir in options.pluginsDirs: for name in glob.glob(os.path.join(pluginDir, '*')): diff --git a/src/commands.py b/src/commands.py index 5619ce6cd..c50735b16 100644 --- a/src/commands.py +++ b/src/commands.py @@ -84,6 +84,14 @@ def process(f, *args, **kwargs): , if supplied, limits the length of execution of target function to seconds.""" timeout = kwargs.pop('timeout', None) + + if conf.disableMultiprocessing: + pn = kwargs.pop('pn', 'Unknown') + cn = kwargs.pop('cn', 'unknown') + try: + return f(*args, **kwargs) + except Exception as e: + return e q = multiprocessing.Queue() def newf(f, q, *args, **kwargs):