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

make --unit-test and --unit-bench target library by default #290

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

carloskiki
Copy link

This is an attempt to resolve #245 as it makes it possible to target the library or binary of a crate with identical library and binary names.

This makes it possible to target the library or binary of a crate with identical library and binary names.
@@ -36,14 +36,16 @@ struct Opt {
#[clap(long, group = "exec-args")]
test: Option<String>,

/// Crate target to unit test, <unit-test> may be omitted if crate only has one target
/// (currently profiles the test harness and all tests in the binary; test selection
/// Crate target to unit test, <unit-test> may be omitted if the crate's library is targeted. To
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we preserve the property that we test whatever the target is if there is a single one? Seems silly to require that we specify the bin target if there is a single target.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is silly. The only way to keep the old behaviour (I think) requires major refactoring regarding the find_single_target function. If there are any future refactoring plans, I am up to the challenge.

Otherwise this is the best way to hot fix it.

Also to add to the explanation of #245, this is quite a major bug/missing feature, as it is really frequent to have a binary in main.rs that relies on the code of its library in lib.rs. There is currently no way of distinguishing between the binary and the library in this type of situation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want this hotfix. Why is the required refactoring so "major"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--unit-test doesnt seem to be able to prioritise lib over bin
2 participants