Skip to main content

test_only_packages

Function test_only_packages 

Source
pub fn test_only_packages<'a>(
    build: &'a [ResolvedPackage],
    root: &'a PackageName,
) -> HashSet<PackageName>
Expand description

The packages of build that nothing but a test-dependencies entry reaches.

resolve walks the union of the two maps whether or not the tests are being compiled, because one version of each package and an acyclic graph are properties of the whole build rather than of one entry point (test-dependencies). What comes back here is the other half of that: which of the packages it found are in the build for the tests alone, so a build that did not ask for the tests can leave them uncompiled instead of parsing, checking and reporting on a package it cannot import.

Reachability is followed through dependencies only, starting from root, so a package reached through test-dependencies that depends on the root stays in this set: nothing on the walk names it. A package written in both maps is not possible — the manifest rejects that — but a package reached through both, as a test-dependency here and an ordinary dependency of something else, is: it comes back out of this set, because an ordinary build needs it.