diff --git a/cargo-nextest/src/dispatch.rs b/cargo-nextest/src/dispatch.rs index 5640b1e5d24..cf01ffab06e 100644 --- a/cargo-nextest/src/dispatch.rs +++ b/cargo-nextest/src/dispatch.rs @@ -456,6 +456,7 @@ impl TestBuildFilter { let mut ignore_filters = Vec::new(); let mut read_trailing_filters = false; + let mut skip_exact = Vec::new(); let mut unsupported_args = Vec::new(); patterns.extend( @@ -473,6 +474,9 @@ impl TestBuildFilter { } else if s == "--" { read_trailing_filters = true; false + } else if s == "--skip" || s == "--exact" { + skip_exact.push(s.clone()); + false } else { unsupported_args.push(s.clone()); true @@ -499,6 +503,13 @@ impl TestBuildFilter { } } + if !skip_exact.is_empty() { + return Err(ExpectedError::test_binary_args_parse_error( + "unsupported\n(hint: use a filter expression instead: )", + skip_exact, + )); + } + if !unsupported_args.is_empty() { return Err(ExpectedError::test_binary_args_parse_error( "unsupported", diff --git a/site/src/book/running.md b/site/src/book/running.md index 71bc014f9d0..407ad7c7a5c 100644 --- a/site/src/book/running.md +++ b/site/src/book/running.md @@ -40,6 +40,17 @@ cargo nextest run ... This is different from `cargo test`, where you have to specify a `--`, for example: `cargo test -- ...`. +### `--skip` and `--exact` + +Nextest does not support `--skip` and `--exact` directly; instead, it supports more powerful [filter expressions](filter-expressions.md) which supersede these options. + +Here are some examples: + +| Cargo test command | Nextest command | +|:-----------------------------------------------:|:-------------------------------------------------------:| +| `cargo test -- --skip skip1 --skip skip2 test3` | `cargo nextest run -E 'test(test3) - test(/skip[12]/)'` | +| `cargo test -- --exact test1 test2` | `cargo nextest run -E 'test(=test1) + test(=test2)'` | + ### Filtering by build platform While cross-compiling code, some tests (e.g. proc-macro tests) may need to be run on the host platform. To filter tests based on the build platform they're for, nextest accepts the `--platform-filter` option with values `target`, `host` or `any` (default). diff --git a/site/src/book/usage.md b/site/src/book/usage.md index 3bb0a17fd49..cb0bca301a3 100644 --- a/site/src/book/usage.md +++ b/site/src/book/usage.md @@ -19,5 +19,4 @@ For more information about running tests, see [Running tests](running.md). To work around this, consider combining those tests into one so that nextest runs them as a unit, or excluding those tests from nextest. * There's [no way](https://github.com/nextest-rs/nextest/issues/28) to mark a particular test binary as excluded from nextest. -* The `--skip` and `--exact` test filter options are currently [not supported](https://github.com/nextest-rs/nextest/issues/29) by nextest. * Doctests are currently [not supported](https://github.com/nextest-rs/nextest/issues/16) because of limitations in stable Rust. Locally and in CI, after `cargo nextest run`, use `cargo test --doc` to run all doctests.