Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cargo tests --skip and --exact command line flags #1483

Closed
svix-jplatte opened this issue May 6, 2024 · 5 comments
Closed
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@svix-jplatte
Copy link
Contributor

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.

@svix-jplatte svix-jplatte changed the title Add support for cargo tests --skip and --exact command line flags Add support for cargo tests --skip and --exact command line flags May 6, 2024
@sunshowers
Copy link
Member

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.

@svix-jplatte
Copy link
Contributor Author

I was able to get it to work, see #1653. It's in draft state though because I broke a test and couldn't really figure out how to add a new one either. And it's quite likely I didn't solve it in the best possible way.

@sunshowers
Copy link
Member

Released as part of cargo-nextest 0.9.80, which will be out within the next 15-20 minutes. Thanks again for your hard work!

@sunshowers
Copy link
Member

Also added documentation: https://nexte.st/docs/running/#--skip-and---exact

@svix-jplatte
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants