Skip to content

Commit 28648fd

Browse files
authored
[Feature] Double-Dash Extra Arguments (#60)
* Implement the double dash extra arguments feature Also including the Unit Tests * Fixing ouput message * Improving parser logic * Fixing lint errors * Improving parser logic for subsequent -- * Fixing the README Notes
1 parent ec1bd24 commit 28648fd

6 files changed

Lines changed: 474 additions & 30 deletions

File tree

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Run `th-cli available-tests` to get a list of tests available in Test Harness, p
5959

6060
### run-tests
6161

62-
Run `th-cli run-tests --tests-list <tests> [--title, -n <title>] [--config, -c <config>] [--pics-config-folder, -p <pics-config-folder>] [--project-id <ID>] [--no-color]` to start a new test execution.
62+
Run `th-cli run-tests --tests-list <tests> [--title, -n <title>] [--config, -c <config>] [--pics-config-folder, -p <pics-config-folder>] [--project-id <ID>] [--no-color] [-- <extra-sdk-args>]` to start a new test execution.
6363

6464
Required:
6565
- `--tests-list`: Comma-separated list of test case identifiers (e.g. --tests-list TC-ACE-1.1,TC_ACE_1_3)
@@ -74,6 +74,7 @@ Optional:
7474
- `--pics-config-folder`: Path to the folder that contains PICS files. If not specified, no PICS file will be used.
7575
- `--project-id`: Project ID that this test run belongs to. If not provided, uses the default 'CLI Execution Project' in TH.
7676
- `--no-color`: Disable all colors from the CLI's output text of this test run execution
77+
- `-- <extra-sdk-args>`: Pass additional arguments directly to the SDK container Python tests. Use the double dash (`--`) separator followed by any SDK test arguments. These arguments will be added to every Python test execution in the run.
7778

7879
**Example config files:**
7980

@@ -106,6 +107,36 @@ Full project format (works with all commands):
106107
}
107108
```
108109

110+
**Passing Extra Arguments to SDK Tests:**
111+
112+
You can pass additional arguments directly to the SDK container test execution using the `--` separator. Everything after `--` will be passed as-is to the Python test runner.
113+
114+
Examples:
115+
```bash
116+
# Enable trace logging for all tests in the run
117+
th-cli run-tests -t TC-ACE-1.1 -- --trace-to json:log
118+
119+
# Pass boolean argument
120+
th-cli run-tests -t TC-ACE-1.1,TC-ACE-1.2 -- --bool-arg flag:true
121+
122+
# Pass multiple extra arguments
123+
th-cli run-tests -t TC-ACE-1.1 -- --timeout 60 --int-arg some-arg:1 --bool-arg flag:true
124+
125+
# Combine with other CLI options
126+
th-cli run-tests -t TC-ACE-1.1 --config my-config.json --no-color -- --trace-to json:log
127+
```
128+
129+
Common SDK test arguments you might want to use for example:
130+
- `--endpoint <value>` - Choose the device endpoint
131+
- `--trace-to json:log` - Enable detailed trace logging
132+
- `--timeout <seconds>` - Override default test timeout
133+
- `--int-arg <name>:<value>` - Pass integer argument to test
134+
- `--bool-arg <name>:<true|false>` - Pass boolean argument to test
135+
- `--string-arg <name>:<value>` - Pass string argument to test
136+
- `--hex-arg <name>:<hex-value>` - Pass hex value argument to test
137+
138+
**Note:** These extra arguments are applied to ALL Test Cases in the test run. Invalid arguments could cause test failures, so ensure the arguments are valid for the SDK test framework.
139+
109140
### test-run-execution-history
110141

111142
Run `th-cli test-run-execution-history` to fetch the history of test runs. Use `--skip` and `--limit` for pagination

tests/conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ def mock_pics_dir(temp_dir: Path) -> Path:
143143
return pics_dir
144144

145145

146+
@pytest.fixture
147+
def sample_default_config_dict() -> dict:
148+
"""Create a sample default configuration dictionary."""
149+
return {
150+
"network": {
151+
"wifi": {
152+
"ssid": "default_wifi",
153+
"password": "default_password"
154+
},
155+
"thread": {
156+
"operational_dataset_hex": "default_hex"
157+
}
158+
},
159+
"dut_config": {
160+
"pairing_mode": "ble-wifi",
161+
"setup_code": "20202021",
162+
"discriminator": "3840",
163+
"trace_log": False
164+
}
165+
}
166+
167+
146168
@pytest.fixture
147169
def mock_api_client() -> Mock:
148170
"""Create a mock API client."""

0 commit comments

Comments
 (0)