diff --git a/scripts/tests/yaml/chiptool.py b/scripts/tests/yaml/chiptool.py index f3a08aa8156d1a..d535f1c942b127 100755 --- a/scripts/tests/yaml/chiptool.py +++ b/scripts/tests/yaml/chiptool.py @@ -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' @@ -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) 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, @@ -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: diff --git a/scripts/tests/yaml/relative_importer.py b/scripts/tests/yaml/relative_importer.py index 3893354bb806a9..7e3cb5aab97085 100644 --- a/scripts/tests/yaml/relative_importer.py +++ b/scripts/tests/yaml/relative_importer.py @@ -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: diff --git a/scripts/tests/yaml/tests_finder.py b/scripts/tests/yaml/tests_finder.py index 99ee4a1350a6c1..2c9d2758d91406 100755 --- a/scripts/tests/yaml/tests_finder.py +++ b/scripts/tests/yaml/tests_finder.py @@ -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