-
Notifications
You must be signed in to change notification settings - Fork 146
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
--unit-test doesnt seem to be able to prioritise lib over bin #245
Comments
I'm honestly not sure I completely understood your bug report. It seems fair that |
To clarify. My project builds as a lib and a single bin. ie I have [[bin] and [lib] entries in my cargo.toml. This is very typical and the bin simply uses the lib. The code from flamegraph below means that both "bin" and "lib" are "searched" when --unit-test is used. And hence no unique target is found.
This results in the error below
If I try and specify that I only want the "bin" considered by running the command with "--bin" option
then I get the error
Hence there appears no way to say although my project consists of a lib and a bin, please do not refuse to run the unit-test thinking I need to specifiy a specific binary. When I change the code below
so that
is used instead, it works, for my project. But this probably isnt the right fix. My project has a single bin and a lib. I notice in the code that there is logic:
Which seems to imply that when unit test is specified that "lib" is prefered. But this doesnt stop me getting the error, as this logic is in the "build()" function, and find_unique_target() function is called first (and fails) with the "several possible targets" error...
|
If you want to submit a fix in a PR, I'd be happy to review it. |
I have also noted this bug, and will open a PR soon. |
Hitting this bug rn -- confirmed that the current build doesn't allow you to flamegraph unit-tests if you have a main & lib with the same name (which is standard practice I think?) |
If you want to help with a fix (seems #290 has stalled) that would be great. |
I created this PR with the simplest solution I could come up with, that just adds a new option, not changing anything else if not used: #322 |
Using --unit-test when my crate builds both a single bin and a single lib fails.
$ cargo flamegraph --unit-test -- my_test
Error: several possible targets found: [BinaryTarget { package: "odonata", target: "odonata", kind: ["lib"] }, BinaryTarget { package: "odonata", target: "odonata", kind: ["bin"] }], please pass an explicit target.
But --unit-test and --bin are incompatible options (and really I want to specify lib somehow)
--verbose doesnt show any additional info
Removing "bin" from the below fixes this - but probably isnt the right fix.
The text was updated successfully, but these errors were encountered: