Skip to content

Commit

Permalink
Allow to filter python test case runs from command line (project-chip…
Browse files Browse the repository at this point in the history
…#36781)

* Allow to filter python test case runs from command line

* Update according to review comment
  • Loading branch information
arkq authored Dec 12, 2024
1 parent 6706f33 commit f3ebc14
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/tests/run_python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ def forward_fifo(path: str, f_out: typing.BinaryIO, stop_event: threading.Event)
@click.option("--quiet/--no-quiet", default=None,
help="Do not print output from passing tests. Use this flag in CI to keep GitHub log size manageable.")
@click.option("--load-from-env", default=None, help="YAML file that contains values for environment variables.")
@click.option("--run", type=str, multiple=True, help="Run only the specified test run(s).")
def main(app: str, factory_reset: bool, factory_reset_app_only: bool, app_args: str,
app_ready_pattern: str, app_stdin_pipe: str, script: str, script_args: str,
script_gdb: bool, quiet: bool, load_from_env):
script_gdb: bool, quiet: bool, load_from_env, run):
if load_from_env:
reader = MetadataReader(load_from_env)
runs = reader.parse_script(script)
Expand All @@ -141,7 +142,11 @@ def main(app: str, factory_reset: bool, factory_reset_app_only: bool, app_args:
"No valid runs were found. Make sure you add runs to your file, see "
"https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md document for reference/example.")

# Override runs Metadata with the command line arguments
if run:
# Filter runs based on the command line arguments
runs = [r for r in runs if r.run in run]

# Override runs Metadata with the command line options
for run in runs:
if factory_reset is not None:
run.factory_reset = factory_reset
Expand Down

0 comments on commit f3ebc14

Please sign in to comment.