From 438c6efdd74d8891d7ca1698f9eb8d015049e2f7 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 28 Apr 2021 12:01:56 +0000 Subject: [PATCH] [IMP] core: JS test runner Emit JS warnings as Python warnings, otherwise it's a pain in the ass to identify the t-raw messages (they get lost in the INFO spam). Also just log exceptions when looking for specific messages instead of re-raising them: if the pipe from chrome is full of exception reports, the runner may blow its stack as it looks for the screenshot message: on the first it takes a screenshot, then looks for the screenshot message, finds an exception, takes a screenshot, looks for a screenshot message, finds an exception, takes a screenshot, looks for a s... --- odoo/tests/common.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index c0040c37000..28a2e5c8e59 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -1051,11 +1051,22 @@ class ChromeBrowser(): res['success'] = 'test successful' in message if res.get('method') == 'Runtime.exceptionThrown': - exception_details = res['params']['exceptionDetails'] - descr = exception_details.get('exception', {}).get('description') - self.take_screenshot() - self._save_screencast() - raise ChromeBrowserException(descr or pprint.pformat(exception_details)) + details = res['params']['exceptionDetails'] + message = details['text'] + exception = details.get('exception') + if exception: + message += str(self._from_remoteobject(exception)) + details['type'] = 'trace' # fake this so _format_stack works + stack = ''.join(self._format_stack(details)) + if stack: + message += '\n' + stack + + if raise_log_error: + self.take_screenshot() + self._save_screencast() + raise ChromeBrowserException(message) + else: + self._logger.getChild('browser').error(message) return res @@ -1063,7 +1074,7 @@ class ChromeBrowser(): 'debug': logging.DEBUG, 'log': logging.INFO, 'info': logging.INFO, - 'warning': logging.INFO, # logging.WARNING, + 'warning': logging.WARNING, 'error': logging.ERROR, # TODO: what do with # dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed,