-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: Deduplicate crates when extending crate graphs #14659
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustbot
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Apr 26, 2023
Veykril
commented
Apr 26, 2023
crates/project-model/src/tests.rs
Outdated
Comment on lines
211
to
238
|
||
#[test] | ||
fn crate_graph_dedup_identical() { | ||
let (mut crate_graph, proc_macros) = | ||
load_cargo_with_sysroot(&mut Default::default(), "regex-metadata.json"); | ||
crate_graph.sort_deps(); | ||
|
||
let (d_crate_graph, mut d_proc_macros) = (crate_graph.clone(), proc_macros.clone()); | ||
|
||
crate_graph.extend(d_crate_graph.clone(), &mut d_proc_macros); | ||
assert!(crate_graph.iter().eq(d_crate_graph.iter())); | ||
assert_eq!(proc_macros, d_proc_macros); | ||
check_crate_graph( | ||
crate_graph, | ||
expect_file!["../test_data/output/crate_graph_dedup_identical.txt"], | ||
); | ||
} | ||
|
||
#[test] | ||
fn crate_graph_dedup() { | ||
let path_map = &mut Default::default(); | ||
let (mut crate_graph, _proc_macros) = | ||
load_cargo_with_sysroot(path_map, "ripgrep-metadata.json"); | ||
assert_eq!(crate_graph.iter().count(), 81); | ||
crate_graph.sort_deps(); | ||
let (regex_crate_graph, mut regex_proc_macros) = | ||
load_cargo_with_sysroot(path_map, "regex-metadata.json"); | ||
assert_eq!(regex_crate_graph.iter().count(), 60); | ||
|
||
crate_graph.extend(regex_crate_graph, &mut regex_proc_macros); | ||
assert_eq!(crate_graph.iter().count(), 118); | ||
check_crate_graph(crate_graph, expect_file!["../test_data/output/crate_graph_dedup.txt"]) | ||
} |
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 no one has to sift through the massive diff due to test files, this is where the tests are :)
@bors r+ |
bors
added a commit
that referenced
this pull request
Apr 26, 2023
Deduplicate crates when extending crate graphs This is quadratic in runtime per deduplication attempt, but I don't think that'll be a problem for the workload here. Don't be scared of the diff, the actual diff is +42 -22, the rest is tests and test data. Fixes #14476
@bors r- |
@bors r+ |
☀️ Test successful - checks-actions |
lnicola
changed the title
Deduplicate crates when extending crate graphs
feat: Deduplicate crates when extending crate graphs
Apr 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is quadratic in runtime per deduplication attempt, but I don't think that'll be a problem for the workload here. Don't be scared of the diff, the actual diff is +42 -22, the rest is tests and test data.
Fixes #14476