Skip to content

Conversation

@ledusledus
Copy link
Contributor

The section on how to run a single test is not precise for cases where test names are substrings of other tests which generates questions like https://stackoverflow.com/questions/54585804/how-to-run-a-specific-unit-test-in-rust.

I propose to point to --exact argument for this case.

@chriskrycho
Copy link
Contributor

Thanks for opening this! We will talk about the best way to proceed here: it is possible we should add this kind of extra explanatory text, but there are also a lot of other details about how to handle things with cargo test which we do not include. In general, people should not expect the book to cover everything (it would be literally 10× the length if it did!) but rather to provide good foundations so that people can successfully discover and learn there rest on their own, e.g. by running cargo help test. (The reason I am not just closing this is because --exact in particular is pretty difficult to find! So I do think we will talk about it, but I think we will probably still end up closing it.)

@chriskrycho
Copy link
Contributor

All right, I did some poking around to figure out where the heck this is documented, and I was surprised to discover that the only place we cover it is in the rustc book, which I had (astonishingly, but not uniquely) never even seen before yesterday as far as I know! I think what I’m inclined to do is link to that page instead. This book does not aim to be comprehensive; indeed it cannot be comprehensive. But this was also a feature I would have liked for a very long time and I always just thought it was a weird gap in Rust’s testing strategy, when it turns out it’s just a not-easy-to-find corner of cargo test and specifically libtest!

Net, I’m going to rewrite this to that effect and push to this branch. Thanks again for opening this; I had no idea about this till you opened the PR!

@chriskrycho
Copy link
Contributor

Ah, it looks like I’ll have to recreate this on top of main, so I’m going to close this and create a new PR which includes your commit plus my change. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants