Skip to content

Commit

Permalink
Merge pull request #97 from oli-obk/crate_id_collision
Browse files Browse the repository at this point in the history
Guard against crate id collisions
  • Loading branch information
oli-obk authored Jul 12, 2023
2 parents 3b9edc5 + 757badb commit 9959dd2
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,24 @@ pub fn build_dependencies(config: &mut Config) -> Result<Dependencies> {
let artifact_output = output.stdout;
let artifact_output = String::from_utf8(artifact_output)?;
let mut import_paths: HashSet<PathBuf> = HashSet::new();
let mut artifacts: HashMap<_, _> = artifact_output
.lines()
.filter_map(|line| {
let message = serde_json::from_str::<cargo_metadata::Message>(line).ok()?;
if let cargo_metadata::Message::CompilerArtifact(artifact) = message {
for filename in &artifact.filenames {
import_paths.insert(filename.parent().unwrap().into());
}
Some((artifact.package_id, artifact.filenames))
} else {
None
let mut artifacts = HashMap::new();
for line in artifact_output.lines() {
let Ok(message) = serde_json::from_str::<cargo_metadata::Message>(line) else {
continue
};
if let cargo_metadata::Message::CompilerArtifact(artifact) = message {
for filename in &artifact.filenames {
import_paths.insert(filename.parent().unwrap().into());
}
let package_id = artifact.package_id;
if artifacts
.insert(package_id.clone(), artifact.filenames)
.is_some()
{
bail!("`ui_test` does not support crates that appear as both build-dependencies and core dependencies: {package_id}")
}
})
.collect();
}
}

// Check which crates are mentioned in the crate itself
let mut metadata = cargo_metadata::MetadataCommand::new().cargo_command();
Expand Down

0 comments on commit 9959dd2

Please sign in to comment.