-
Notifications
You must be signed in to change notification settings - Fork 2.6k
WIP: Add normalized querykind Fixes #1079 #10985
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
Changes from all commits
76fefef
8699500
21d72dd
cb8cbb8
19e506f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,15 @@ impl<'cfg> Source for DirectorySource<'cfg> { | |
let packages = self.packages.values().map(|p| &p.0); | ||
let matches = packages.filter(|pkg| match kind { | ||
QueryKind::Exact => dep.matches(pkg.summary()), | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Why the source check? |
||
if src_id.is_path() { | ||
dep.matches(pkg.summary()) | ||
} else { | ||
true | ||
} | ||
} | ||
}); | ||
for summary in matches.map(|pkg| pkg.summary().clone()) { | ||
f(summary); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -739,7 +739,8 @@ impl<'cfg> Source for RegistrySource<'cfg> { | |
.query_inner(dep, &mut *self.ops, &self.yanked_whitelist, &mut |s| { | ||
let matched = match kind { | ||
QueryKind::Exact => dep.matches(&s), | ||
QueryKind::Fuzzy => true, | ||
QueryKind::Alternatives => true, | ||
QueryKind::Normalized => true, | ||
Comment on lines
740
to
+743
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So both the test and running by hand via There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
}; | ||
if matched { | ||
f(s); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Please put this in with the other cargo add tests ( |
||
let p = project() | ||
.file("src/lib.rs", "") | ||
.file( | ||
"Cargo.toml", | ||
r#"[package] | ||
name = "example" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
xml-rs = "0.8.4""#, | ||
) | ||
.build(); | ||
Package::new("xml-rs", "0.8.4").publish(); | ||
Package::new("cbindgen", "0.9.4").publish(); | ||
|
||
p.cargo("vendor ./vendor") | ||
.with_stdout( | ||
r#" | ||
[source.crates-io] | ||
replace-with = "vendored-sources" | ||
|
||
[source.vendored-sources] | ||
directory = "./vendor""#, | ||
) | ||
.run(); | ||
p.change_file( | ||
".cargo/config", | ||
r#" | ||
[source.crates-io] | ||
replace-with = "vendored-sources" | ||
|
||
[source.vendored-sources] | ||
directory = "./vendor""#, | ||
); | ||
p.cargo("add cbindgen") | ||
// current output | ||
//.with_stdout(r#"warning: translating `cbindgen` to `xml-rs` | ||
//Adding xml-rs v0.8.4 to dependencies."#) | ||
// correct output | ||
.with_stdout( | ||
r#" Updating crates.io index | ||
Adding xml-rs v0.8.4 to dependencies."#, | ||
) | ||
.run(); | ||
} |
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.