Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Improve PackageLink::dev_only documentation to indicate that it's local context only #420

Open
nasifimtiazohi opened this issue Aug 12, 2021 · 1 comment

Comments

@nasifimtiazohi
Copy link

nasifimtiazohi commented Aug 12, 2021

Shouldn't an edge to any dependency to a dev dependency of a project be a dev_only edge? However, this API, guppy::graph::PackageLink::dev_only, returns false for such an edge. In this way, I am not sure how this API is different from guppy::graph::PackageLink::dev()::is_present().

For example, for a test crate that has guppy as a dev dependency and no other dependency specified in the crate to make sure guppy doesn't appear elsewhere in the dep-graph, below code

// The crate has a single dependency, `guppy` as a dev-dependency
let pkg = graph.packages().find(|p| p.name() == "guppy").unwrap();
for link in pkg.direct_links_directed(DependencyDirection::Forward){
    println!("{:?}, {:?}, {:?}, {:?}",
    link.to().name(), link.normal().is_present(),
    link.dev().is_present(), link.dev_only());
}

outputs:

running 1 test
"target-spec", true, false, false
"supercow", true, false, false
"serde_json", true, false, false
"serde", true, false, false
"semver", true, false, false
"petgraph", true, false, false
"pathdiff", true, false, false
"once_cell", true, false, false
"nested", true, false, false
"itertools", true, false, false
"indexmap", true, false, false
"fixedbitset", true, false, false
"cargo_metadata", true, false, false
"camino", true, false, false

However, guppy::graph::PackageLink::dev_only in its description says:

Return true if this edge is dev-only, i.e. code from this edge will not be included in normal builds.

Below is how my test crate looked like:

[dependencies]


[build-dependencies]

[dev-dependencies]
guppy = "0.9.0"

@sunshowers
Copy link
Contributor

sunshowers commented Aug 13, 2021

Ahh I see what's going on there. PackageLinks only have local context: if guppy is built as a normal dependency, then these would be included as normal dependencies as well.

For the sort of global context you're looking for I think you can use the Cargo build simulation feature: https://docs.rs/guppy/0.9.0/guppy/graph/feature/struct.FeatureSet.html#method.into_cargo_set

The documentation could be improved here; I'll leave this issue open for that.

@sunshowers sunshowers changed the title Edge to a normal dependency to a dev dependency should be dev only? Improve PackageLink::dev_only documentation to indicate that it's local context only Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants