-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
WIP: Add normalized querykind Fixes #1079 #10985
Conversation
- As described [in this issue](#10729 (comment)) rename `Fuzzy` to `Alternatives` for clarity
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
I didn't look into the issue. Just remind that the test seems to perform real network requests. You may take existing tests as reference for setting up a fake registry and dependencies. |
You're definitely right, I updated my test to reflect that. However I'm still having some issues which I need to debug in under to get a better understand to be able to ask the right questions. The test now replicates the original error and makes an assertion of what the correct output should be. It's still not passing though. Right now I can setup a debugger in VSCode but don't know how to attach it to the cargo process itself so I can debug what's actually happening in the test (hope that makes sense). I know how to do it with CLion I think, so I'm going to try to buy the license for that so I can get the debugger going. Thanks for the comment! I'll be back with a better understanding after I get the debugger running and attaching it to the actual |
QueryKind::Fuzzy => true, | ||
QueryKind::Alternatives => true, | ||
QueryKind::Normalized => { | ||
let src_id = pkg.package_id().source_id(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the source check?
use cargo_test_support::{project, registry::Package}; | ||
|
||
#[cargo_test] | ||
fn carg_add_with_vendored_packages() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put this in with the other cargo add tests (tests/testsuite/cargo_add
) and look to the tests in there for how they should be written (its using the document UI test pattern)
let matched = match kind { | ||
QueryKind::Exact => dep.matches(&s), | ||
QueryKind::Fuzzy => true, | ||
QueryKind::Alternatives => true, | ||
QueryKind::Normalized => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test now replicates the original error and makes an assertion of what the correct output should be. It's still not passing though.
Put an assert in here and run your tests. My guess is this code isn't being hit.
My guess is we are "publishing" the packages to a directory registry which will be hitting the directory.rs
code path rather than the registry/mod.rs
code path.
maybe if we setup a sparse/http registry in the test, we could reproduce this.
Another alternative is we go past the MVP solution and implement normalization for all sources.
The final alternative is that we don't have a test for this. As the note above hints at, we are only testing one source type's normalization and there would be two main classes of normalization here. Unless we went and verified all sources, there isn't really much of a difference between implementing the feature for a different code path and testing it vs just not testing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: also as part of characterizing this, have you been able to reproduce the expected behavior by hand by running cargo run -- add ...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So both the test and running by hand via ../<snip>/target/debug/cargo add ...
are hitting the code in src/cargo/sources/registry/mod.rs
actually. I am not able to reproduce the expected behavior by hand, I still get the original error. So seems like I am missing something in the implementation here. I need to actually dig into it more and get some context which might take me a day or two more. I'll try to come back with a solution or a pointed question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: Haven't given up at all, but had to pack up my family members house being sold this week. Will have time to dig in this weekend.
/// Behavior like `Exact` for path sources and like `Alternatives` for | ||
/// registry sources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please focus on the desired behavior, and not the implementation, for the comment.
This one will match a dependency in all ways except it will normalize the package name. Each source defines what normalizing means.
Thank you @epage extensively for your extremely generous review and welcome in Zulip. I'll look into these things today and fix them up. This is awesome. I'm so excited to be learning and contributing to |
Ping @goodSyntax808. Checking in to see if you still got time to sort this out, or if you had any questions. Feel free to continue the discussion here or on Zuilp. |
☔ The latest upstream changes (presumably #11937) made this pull request unmergeable. Please resolve the merge conflicts. |
What does this PR try to resolve?
See this thread, particularly this comment
How should we test and review this PR?
Currently trying to get a functional or ui test to work but am having issues.
If you don't know how to write and run your tests, please read the guide:
https://doc.crates.io/contrib/tests
Additional information
TODO:
.cargo/config.toml
file intests/testsuite/<command>/<case>/in
to be persisted. I have this test on another branch,add-normalized-querykind-test
, which is justmaster
+ tests.Click to expand