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

Make chiptool.py a little easier to understand #30416

Merged
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
21 changes: 17 additions & 4 deletions scripts/tests/yaml/chiptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import sys
from typing import List

import chiptest
import click
from paths_finder import PathsFinder
from runner import CONTEXT_SETTINGS, chiptool
from tests_finder import TestsFinder
from tests_tool import send_raw_command, send_yaml_command

_DEFAULT_EXTENSIONS_DIR = 'scripts/tests/yaml/extensions'
Expand All @@ -31,11 +33,11 @@

def chiptool_runner_options(f):
f = click.option('--server_path', type=click.Path(exists=True), default=None,
help='Path to an websocket server to run at launch.')(f)
help='Path to a websocket server that will be executed to forward parsed command. Most likely you want to use chiptool.')(f)
f = click.option('--server_name', type=str, default='chip-tool',
help='Name of a websocket server to run at launch.')(f)
help='If server_path is not provided, we use this argument to seach various directories within SDK binary that matches this name.')(f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be more like:

If server_path is not provided, we use this argument to seach various directories within the SDK for a binary that matches this name

f = click.option('--server_arguments', type=str, default='interactive server',
help='Optional arguments to pass to the websocket server at launch.')(f)
help='Arguments to pass to the websocket server at launch.')(f)
f = click.option('--show_adapter_logs', type=bool, default=False, show_default=True,
help='Show additional logs provided by the adapter.')(f)
f = click.option('--trace_file', type=click.Path(), default=None,
Expand Down Expand Up @@ -89,7 +91,18 @@ def chiptool_py(ctx, commands: List[str], server_path: str, server_name: str, se
server_arguments = maybe_update_server_arguments(ctx)
maybe_update_stop_on_error(ctx)

if len(commands) > 1 and commands[0] == 'tests':
if len(commands) == 1 and commands[0] == 'list':
print('List of all individual tests that can be run:')
for test in chiptest.AllChipToolYamlTests():
print(f' {test.name}')

tests_finder = TestsFinder()
tests_collections = tests_finder.get_collections()
if tests_collections:
print('\nList of all collections tests that can be run:')
for test in tests_collections:
print(f' {test}')
elif len(commands) > 1 and commands[0] == 'tests':
success = send_yaml_command(chiptool, commands[1], server_path, server_arguments, show_adapter_logs, specifications_paths, pics,
additional_pseudo_clusters_directory, commands[2:])
else:
Expand Down
5 changes: 5 additions & 0 deletions scripts/tests/yaml/relative_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
EXAMPLES_PATH = os.path.join(DEFAULT_CHIP_ROOT, 'examples')
REPL_PATH = os.path.join(DEFAULT_CHIP_ROOT, 'src', 'controller', 'python')

try:
import chiptest # noqa: F401
except ModuleNotFoundError:
sys.path.append(os.path.join(SCRIPT_PATH, 'tests'))

try:
import matter_idl # noqa: F401
except ModuleNotFoundError:
Expand Down
3 changes: 3 additions & 0 deletions scripts/tests/yaml/tests_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def get(self, test_name: str) -> List[str]:

return self.__get_paths(test_names)

def get_collections(self) -> List[str]:
return self.__test_collections

def __get_collections(self, configuration_directory: str, configuration_name: str) -> List[str]:
if os.path.isfile(configuration_name):
configuration_filepath = configuration_name
Expand Down