Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update runner run function to be async. #27048

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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