-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Provide a way to uniquely identify a test? #2941
Comments
I'd be fine doing this, yeah, but wouldn't it amount to basically the same thing? You'd basically end up doing:
Cargo doesn't actually know anything about the names of tests (they're all part of the test harness, which Cargo is opaque to), so it may be somewhat difficult to pass that kind of information down or parse it out as well. |
Yeah, this is exactly the idea: consolidate different pieces of information about test location into the single string. It just doesn't feel right to me that you need more than one flag to specify the test. But the main point of the issue is to raise a concern that running a single test is a bit difficult at the moment, and I sincerely don't know what is the right solution here, the test harness and cargo are indeed independent :) When workspaces are fully implemented, how one would run a single test from some target from some package of a workspace? |
I guess yeah we could benefit from baking this into Cargo itself. I'd suspect that IDEs could have their own layer and the in the translation step of "take this string and call Cargo" it'd be hairy, but not too bad logic. The downside there though is each IDE may make its own syntax, and that'd be bad! Right now the idea to run tests anywhere would be:
|
Note that Cargo being so disconnected from the test harness has come up repeatedly in many many issues, so it may just be high time to wed the two together. |
Another issue that I believe could be filed under this one is that it's currently impossible to uniquely identify a test whose name is a prefix of another test. For example, if I have the tests In Go, this is solved by making the test name pattern a regex. Perhaps something similar could be done for Cargo? |
Well, yes and no — it's necessary for the test harness to support such a feature, but Cargo should also expose it for it to be useful. You're right that something like regex matching would need to be added to |
It is available. You can pass arguments directly to the test harness after
|
@matklad that seems like a rather roundabout way of getting at a fairly commonplace feature..? |
I'd argue the more commonplace feature is just being able to somewhat filter down the tests, for which cargo has explicit support for: https://github.com/rust-lang/cargo/blob/0.33.0/src/bin/cargo/commands/test.rs#L126
How high time is it, compared to the competing priorities for 2019-2021? Should we add it to next meeting's agenda?
I prefer I was about to mention that we've started discussing the extraction of some stable reusable modules for cargo (first one being discussed in oli-obk/cargo_metadata#63), but I just realise that doesn't help you in IntelliJ Rust, seeing as it's in Kotlin. |
Btw, if anyone wants to join me, I've kind of being on a little bit of a campain for a feature in libtest: rust-lang/rust#30422 |
FWIW, I am inclined to close this: UI-wise, I think As for machine friendlies, yeah, it's quite a boilerplate to specify all the various flags, but you write it once and forget about it. |
Currently Cargo + test harness allow to easily identify a test inside the crate by specifying a
::
separated path. However this does not uniquely identify a test, because it may live in different crates.Today, cargo provides
--lib
,--bin name
,--example name
etc flags to select a test binary. I think this is a bit suboptimal:--lib
)So perhaps we need to invent some kind of fully-qualified test name? Something along the lines of
::package_name::target_withing_a_package::harness_specific_name
?The text was updated successfully, but these errors were encountered: