Skip to content

Commit a2c8cbf

Browse files
docs(testkit): show how to exclude tests by capability
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent fff4201 commit a2c8cbf

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎tests/testkit/README.md‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ async fn long_running_exec_delete(cx: &mut Context) -> testkit::Result {
4040
`#[testkit::test(id = "...", requires = [service_exposure])]`. The names are
4141
the boolean fields of `capabilities` in the target file. An unknown name
4242
fails to compile. If the target lacks a required capability, the test
43-
fails rather than passing untested, so exclude it when you select tests.
43+
fails rather than passing untested. See
44+
[Excluding tests by capability](#excluding-tests-by-capability).
4445
- **The function name is the nextest test name.** Rename it freely; the ID
4546
keeps the history.
4647

@@ -106,6 +107,21 @@ cargo nextest run --manifest-path <suite>/Cargo.toml --test-threads 1
106107
`testkit-ready [TIMEOUT_SECS]` exits non-zero if the gateway is not healthy in
107108
time or the target's CLI does not report it connected.
108109

110+
### Excluding tests by capability
111+
112+
Nothing selects tests by capability yet, so a test whose `requires` the target
113+
does not provide fails with `requires <capability>, which the target does not
114+
provide`. Find those tests and exclude them by name with a nextest filter:
115+
116+
```shell
117+
grep -rn 'requires = \[' <suite>/tests
118+
cargo nextest run --manifest-path <suite>/Cargo.toml --test-threads 1 \
119+
-E 'not test(=stopped_sandbox_keeps_workspace)'
120+
```
121+
122+
Combine names with `or` inside the parentheses, for example
123+
`-E 'not (test(=a) or test(=b))'`.
124+
109125
## Checks
110126

111127
```shell

0 commit comments

Comments
 (0)