Skip to content

Commit 68a6181

Browse files
chore(tools): allow args of run-tests to be passed to riot (#15525)
## Description previously running the script `./scripts/run-tests` with arguments `-- [any remaining arguments here]` would send all the remaining arguments to pytest via riot. So previously we could do `./scripts/run-tests test_file.py -- -k test_name` With this change, the arguments are passed first to riot allowing for example `./scripts/run-tests test_file.py -- -s -- -k test_name` here the `-s` option is passed to riot (allowing much faster test start step, as it won't recompile everything, (but, most of the time, it will only works if you already run the test without `-s`) and then `-k test_name` is used as a pytest option. If you want the previous behavior, you have to add 2 `-- --` to pass everything to pytest. `./scripts/run-tests test_file.py -- -- -k test_name` ## Motivation `-s` option is a big time saver when investigating a problem. Other riot options may be useful too. --------- Co-authored-by: T. Kowalski <[email protected]>
1 parent b93a092 commit 68a6181

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

.claude/skills/run-tests/SKILL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ When you modify files like:
8484
#### For Test-Only Changes
8585
When you modify `tests/` files (but not test infrastructure):
8686
- Run only the specific test files/functions modified
87-
- Use pytest args: `-- -k test_name` or direct test file paths
87+
- Use pytest args: `-- -- -k test_name` or direct test file paths
8888

8989
#### For Test Infrastructure Changes
9090
When you modify:
@@ -121,7 +121,7 @@ This will:
121121

122122
For re-running specific tests:
123123
```bash
124-
scripts/run-tests --venv <hash> -- -vv -k test_name
124+
scripts/run-tests --venv <hash> -- -- -vv -k test_name
125125
```
126126

127127
## When Tests Fail
@@ -243,15 +243,15 @@ scripts/run-tests --list tests/contrib/flask/test_views.py
243243
# Output shows: contrib::flask suite
244244

245245
# Run just the specific test:
246-
scripts/run-tests --venv flask_py311 -- -vv tests/contrib/flask/test_views.py
246+
scripts/run-tests --venv flask_py311 -- -- -vv tests/contrib/flask/test_views.py
247247
```
248248

249249
### Example 4: Iterating on a Failing Test
250250

251251
First run shows one test failing:
252252

253253
```bash
254-
scripts/run-tests --venv flask_py311 -- -vv -k test_view_called_twice
254+
scripts/run-tests --venv flask_py311 -- -- -vv -k test_view_called_twice
255255
# Focused on the specific failing test with verbose output
256256
```
257257

@@ -330,7 +330,7 @@ The `scripts/run-tests` system:
330330
- Uses `riot` to manage multiple Python/package combinations as venvs
331331
- Each venv is a self-contained environment
332332
- Docker services are managed per suite lifecycle
333-
- Tests can pass optional pytest arguments with `--`
333+
- Tests can pass optional pytest arguments with `-- --`
334334

335335
### Supported Suite Types
336336

docs/contributing-testing.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,14 @@ The ``scripts/run-tests`` script handles this automatically:
8181

8282
.. code-block:: bash
8383
84+
# Add riot arguments to avoid unnecessary compilation
85+
$ scripts/run-tests tests/contrib/django/ -- -s
86+
8487
# Add pytest arguments for test selection
85-
$ scripts/run-tests tests/contrib/django/ -- -k test_specific_function
86-
$ scripts/run-tests ddtrace/contrib/django/patch.py -- -vvv -s --tb=short
88+
$ scripts/run-tests tests/contrib/django/ -- -- -k test_specific_function
89+
90+
# Add both riot (first) and pytest (second) arguments
91+
$ scripts/run-tests ddtrace/contrib/django/patch.py -- -s -- -vvv -s --tb=short
8792
8893
# Run specific test functions
8994
$ scripts/run-tests tests/contrib/flask/ -- -k "test_request or test_response"

scripts/run-tests

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ class TestRunner:
523523

524524
# Add riot args if provided
525525
if riot_args:
526-
cmd.extend(["--"] + riot_args)
526+
cmd.extend(riot_args)
527527

528528
if dry_run:
529529
print(f"[DRY RUN] Would execute: {' '.join(cmd)}")
@@ -655,8 +655,14 @@ Examples:
655655
# Show what would be run without executing
656656
scripts/run-tests --dry-run
657657
658+
# Pass additional arguments to riot
659+
scripts/run-tests ddtrace/contrib/django/patch.py -- -s
660+
658661
# Pass additional arguments to pytest
659-
scripts/run-tests ddtrace/contrib/django/patch.py -- -vvv -s --tb=short
662+
scripts/run-tests ddtrace/contrib/django/patch.py -- -- -vvv -s --tb=short
663+
664+
# Pass additional arguments to riot (first) and pytest (second)
665+
scripts/run-tests ddtrace/contrib/django/patch.py -- -s -- -vvv -k api --tb=short
660666
""",
661667
)
662668

0 commit comments

Comments
 (0)