Skip to content

refactor(cli): tests construct Config directly - #216

Draft
ecalifornica wants to merge 1 commit into
robert/config-search-pathfrom
robert/config-test-env
Draft

refactor(cli): tests construct Config directly#216
ecalifornica wants to merge 1 commit into
robert/config-search-pathfrom
robert/config-test-env

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Part of #187. path-cli only. No library changes. No user-visible changes.

What

  • The resume integration tests build a Config against a TestHome tempdir and pass it to run_with_strategy. No test reads or mutates the process environment. Test assertions derive their expected paths from the tempdir.
  • The Config fields are pub so a test crate can construct one. The struct stays #[doc(hidden)]; Config::load is the only production constructor. Integration tests are separate crates and cannot see #[cfg(test)] items.
  • Deleted: ScopedHome, support::env_lock(), config::TEST_ENV_LOCK. The figment::Jail tests hold no extra lock: Jail serializes its own tests, and no other test touches the environment.

Fixed sandbox escape

With $XDG_DATA_HOME set, the opencode resume test wrote into the developer's real ~/.local/share/opencode/opencode.db: the guard pinned $HOME, but Config::load picked up the real $XDG_DATA_HOME and the resolver preferred it. A directly-constructed Config carries only sandbox paths (every field outside home and toolpath_config_dir is None), so all seven harness resolvers root under the sandbox. Verified by running the suite with decoy XDG_DATA_HOME and COPILOT_HOME values: the decoy directory stays empty.

@ecalifornica ecalifornica changed the title robert/config test env refactor(cli): tests construct Config directly Aug 14, 2026
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://5300407d.toolpath.pages.dev

@ecalifornica
ecalifornica force-pushed the robert/config-test-env branch from d07bf68 to 566d3c1 Compare August 14, 2026 19:49
The path-cli integration tests build a Config value against a tempdir
instead of mutating the process environment. The Config fields are
public so a separate test crate can construct one; Config::load stays
the only production constructor.

ScopedHome, the test environment locks, and the environment reads in
test assertions are deleted. Test assertions derive their expected
paths from the tempdir. Every Config field outside home and
toolpath_config_dir stays None, so all seven harness resolvers root
under the sandbox home.

figment::Jail restores the variables it sets and serializes its own
tests, so the three Jail tests need no extra lock.
@ecalifornica
ecalifornica force-pushed the robert/config-test-env branch from 566d3c1 to 4962d9d Compare August 18, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant