From 579d40ef51c5cfe34ebc84f254aba48b7f40d907 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Fri, 19 May 2023 11:12:02 +0200 Subject: [PATCH] [matter_yamltests] Do not include the pre/post processing to the test timeout --- .../matter_yamltests/runner.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/py_matter_yamltests/matter_yamltests/runner.py b/scripts/py_matter_yamltests/matter_yamltests/runner.py index f87f94d53dc993..6f201c8ea6ad74 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/runner.py +++ b/scripts/py_matter_yamltests/matter_yamltests/runner.py @@ -144,8 +144,8 @@ def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: Tes continue loop = asyncio.get_event_loop() - result = loop.run_until_complete(asyncio.wait_for( - self._run(parser, runner_config), parser.timeout)) + result = loop.run_until_complete( + self._run_with_timeout(parser, runner_config)) if isinstance(result, Exception): raise (result) elif not result: @@ -157,11 +157,20 @@ def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: Tes return parser_builder.done - async def _run(self, parser: TestParser, config: TestRunnerConfig): + async def _run_with_timeout(self, parser: TestParser, config: TestRunnerConfig): status = True try: await self.start() + status = await asyncio.wait_for(self._run(parser, config), parser.timeout) + except Exception as exception: + status = exception + finally: + await self.stop() + return status + async def _run(self, parser: TestParser, config: TestRunnerConfig): + status = True + try: hooks = config.hooks hooks.test_start(parser.filename, parser.name, parser.tests.count) @@ -214,5 +223,4 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig): except Exception as exception: status = exception finally: - await self.stop() return status