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

Open
svix-jplatte opened this issue May 6, 2024 · 1 comment
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@svix-jplatte
Copy link

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.

@sunshowers sunshowers added enhancement New feature or request help wanted Extra attention is needed labels May 6, 2024
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