Skip to content

Commit

Permalink
Update runner run function to be async. (#27048)
Browse files Browse the repository at this point in the history
  • Loading branch information
krypton36 authored and pull[bot] committed Aug 15, 2023
1 parent 8359f06 commit 4358124
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 2 additions & 4 deletions scripts/py_matter_yamltests/matter_yamltests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def execute(self, request):
async def stop(self):
return

def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: TestRunnerConfig):
async def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: TestRunnerConfig):
if runner_config and runner_config.hooks:
start = time.time()
runner_config.hooks.start(len(parser_builder_config.tests))
Expand All @@ -143,9 +143,7 @@ def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: Tes
if not parser or not runner_config:
continue

loop = asyncio.get_event_loop()
result = loop.run_until_complete(
self._run_with_timeout(parser, runner_config))
result = await self._run_with_timeout(parser, runner_config)
if isinstance(result, Exception):
raise (result)
elif not result:
Expand Down
16 changes: 11 additions & 5 deletions scripts/tests/yaml/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import relative_importer # isort: split # noqa: F401

import asyncio
import importlib
import os
import sys
Expand Down Expand Up @@ -269,7 +270,8 @@ def parse(parser_group: ParserGroup):
runner_config = None

runner = TestRunner()
return runner.run(parser_group.builder_config, runner_config)
loop = asyncio.get_event_loop()
return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config))


@runner_base.command()
Expand All @@ -279,7 +281,8 @@ def dry_run(parser_group: ParserGroup):
runner_config = TestRunnerConfig(hooks=TestRunnerLogger())

runner = TestRunner()
return runner.run(parser_group.builder_config, runner_config)
loop = asyncio.get_event_loop()
return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config))


@runner_base.command()
Expand All @@ -293,7 +296,8 @@ def run(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop_on_wa
runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks)

runner = TestRunner()
return runner.run(parser_group.builder_config, runner_config)
loop = asyncio.get_event_loop()
return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config))


@runner_base.command()
Expand All @@ -316,7 +320,8 @@ def websocket(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop
server_address, server_port, server_path, server_arguments, websocket_runner_hooks)

runner = WebSocketRunner(websocket_runner_config)
return runner.run(parser_group.builder_config, runner_config)
loop = asyncio.get_event_loop()
return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config))


@runner_base.command()
Expand All @@ -331,7 +336,8 @@ def chip_repl(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop
runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks)

runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, commission_on_network_dut)
return runner.run(parser_group.builder_config, runner_config)
loop = asyncio.get_event_loop()
return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config))


@runner_base.command()
Expand Down

0 comments on commit 4358124

Please sign in to comment.