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

Filter and build integration tests needed only #8282

Closed
pickfire opened this issue May 26, 2020 · 7 comments · Fixed by #8552
Closed

Filter and build integration tests needed only #8282

pickfire opened this issue May 26, 2020 · 7 comments · Fixed by #8552
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` E-easy Experience: Easy

Comments

@pickfire
Copy link
Contributor

Describe the problem you are trying to solve

There is a project with 20+ integration tests, it takes like few minutes to build all of them. Even with a small change in one of the tests file and I wanted to just run one of the tests file, I did cargo tests part_a but it still compiles everything again.

The solution right now,

  1. rm tests/*
  2. git restore tests/part_a.rs
  3. cargo test part_a, try rebuilding
  4. git restore src/dep.rs, add some dependencies needed

Essentially, this will also remove the issue of clogging the screen with 0 tests run and the need to scroll up multiple times to search for the tests run #4324.

Describe the solution you'd like

Search for the functions used in the filter (cargo test <filter>), build and run only those files needed. Something like ripgrep for function name, but this requires cargo to include the dependencies too.

This provides 2 benefits, reducing the need to build unneeded files and prevent clogging the screen by running file without tests matching the filter.

Notes

I would like to take on this issue if the complexity is not high or if there are people willing to mentor.

@pickfire pickfire added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label May 26, 2020
@alexcrichton
Copy link
Member

Thanks for the report, but cargo test part_a does not mean, to Cargo, "run the part_a test" but it instead means "pass part_a to all test executables as an argument". To run only one test you can use --test part_a, and then Cargo won't build the other targets.

@pickfire
Copy link
Contributor Author

Ah, I did not know cargo --test part_a exists, I believe it would be nice to add an example for that. Yes, all my functions are prefixed with part_a, so cargo test part_a should work.

@ehuss ehuss added A-documenting-cargo-itself Area: Cargo's documentation E-easy Experience: Easy labels Jun 25, 2020
@ehuss
Copy link
Contributor

ehuss commented Jun 25, 2020

I think this is already documented in the cargo test man page. There is an example for exactly this case at the bottom of https://doc.rust-lang.org/cargo/commands/cargo-test.html. However, I think it would be reasonable to emphasize how target selection works at the top where it introduces test filtering.

@pickfire
Copy link
Contributor Author

Ah, I just realized it is documented in cargo test man page, I rarely read cargo man pages since it is more troublesome to read it, like I need to rustup man cargo-test rather than just alt-h in fish to show the man page since it is not in the MANPATH, so usually I just rustup test --help. Should we add rustup man pages to the MANPATH during installation?

@icorbrey
Copy link

Mind if I take a stab at this? I haven't been able to contribute to an OSS project before so I'm trying to find ways to help out. It looks like I should be able to add specific wording in src/doc/man/cargo-test.adoc to emphasize the usage of --test

@pickfire
Copy link
Contributor Author

@icorbrey Yes, definitely. It would be good to make the wordings simpler and clearer. One thing I like is https://github.com/Dhghomon/easy_rust

@icorbrey
Copy link

I think that adding the rust manuals to the MANPATH would be good, but that's probably outside the scope of this issue lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants