-
Notifications
You must be signed in to change notification settings - Fork 0
Inject an Env seam into home directory resolution #486
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestmediumRoadmap items to schedule within the current quarter. Clear scope, normal review cycles.Roadmap items to schedule within the current quarter. Clear scope, normal review cycles.refactorBehaviour-preserving restructuring that improves code health.Behaviour-preserving restructuring that improves code health.testingTest coverage, test infrastructure, and verification tooling work.Test coverage, test infrastructure, and verification tooling work.
Description
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestmediumRoadmap items to schedule within the current quarter. Clear scope, normal review cycles.Roadmap items to schedule within the current quarter. Clear scope, normal review cycles.refactorBehaviour-preserving restructuring that improves code health.Behaviour-preserving restructuring that improves code health.testingTest coverage, test infrastructure, and verification tooling work.Test coverage, test infrastructure, and verification tooling work.
Context
home_from_envinsrc/stdlib/path/path_utils.rs:155-170reads up to five environment variables ambiently, across two#[cfg]branches:This is the worst offender in the codebase for ambient environment access: a five-variable precedence ladder with an empty-string edge case, none of which can be exercised without mutating the real environment. The Windows branch is additionally unreachable from the CI host. Under the AGENTS.md testing mandate it currently has no legitimate test route at all.
Required work
Fn(&str) -> Option<String>) inhome_from_envand its callers, supplying the process-backed reader at thestdlib::pathboundary.#[cfg(windows)]ladder testable independently of the host by extracting the precedence logic into acfg-free helper that takes the injected environment, leaving only the platform selection behind#[cfg].rstestcases covering:HOMEset;HOMEunset withUSERPROFILEset; theHOMEDRIVE/HOMEPATHpair; the empty-HOMEPATHedge case falling through toHOMESHARE; and nothing set.Acceptance criteria
env::varcall remains insrc/stdlib/path/path_utils.rs.make check-fmt,make lint, andmake testpass.Amended 2026-08-05: the injection requirement originally named
mockable::Env/mockable::DefaultEnv. The repository's established seam for this boundary is a closure reader (as instdlib::path,output_mode,output_prefs, andtheme), and adding a trait-object dependency for one call site is disproportionate; the requirement now states the closure seam that PR #499 implements. The substance — no ambientenv::varinpath_utils.rs, both ladders testable from a Unix host — is unchanged.