nextest-rs/nextest

Add support for `cargo test`s --skip and --exact command line flags

Opened this issue · 1 comments

Hi, I was just looking for an issue about --skip in nextest and found #29 which is saying that these are supported, but using different syntax. This is problematic for my use case since I have a test script that runs cargo nextest run if available, but falls back to regular cargo test if nextest is not installed. I also think that for interactive usage, --skip and --exact are much easier to use than the filter expression syntax.

Would you consider adding support for these flags? The implementation could just instantiate the appropriate filter expressions internally, so it should be really simple.

Hi -- I was hesitant to add this at first, but over the last few months I've changed my mind. I'm happy to accept a PR for this. Some notes:

  • --skip and --exact should only be accepted after cargo nextest run -- -- the point after -- is where we accept test binary args. See
    patterns.extend(
    self.filters
    .iter()
    .filter(|&s| {
    if read_trailing_filters || !s.starts_with('-') {
    true
    } else if s == "--include-ignored" {
    ignore_filters.push((s.clone(), RunIgnored::All));
    false
    } else if s == "--ignored" {
    ignore_filters.push((s.clone(), RunIgnored::IgnoredOnly));
    false
    } 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
    }
    })
    .cloned(),
    .
  • Just like the existing support, filter expressions must be ANDed with them. i.e. if both a filter expression and --skip/--exact is passed in, both should be matched for a test to be run.
  • I'm not exactly sure of the semantics of --skip and --exact especially when they're passed in together, so a full description of the semantics, with tests would be wonderful.