Skip to content

test(cli): isolate controller fixture command lookup - #1333

Merged
yyjeqhc merged 1 commit into
yyjeqhc:mainfrom
skygunner:contrib/cli-controller-fixture-path-20261028
Oct 28, 2026
Merged

yyjeqhc merged 1 commit into
yyjeqhc:mainfrom
skygunner:contrib/cli-controller-fixture-path-20261028

Conversation

@skygunner

Copy link
Copy Markdown
Contributor

Problem

controller_tui test fixtures run scripts through /bin/sh. The child inherited the test process's global PATH, and other tests in this binary legitimately replace that process-global environment. When a concurrently running test had rewritten PATH, the fixture's external utility lookups failed non-deterministically (observed as sleep: command not found), producing failures unrelated to the behavior under test.

Change

The fixture now sets a child-local PATH (/usr/bin:/bin) on the spawned shell instead of inheriting the process environment. This is test-only: no production code, CLI behavior, or global environment is modified.

The regression runs the fixture in an isolated child process whose inherited PATH contains no shell utilities. The fixture's own script calls an external utility (sleep), so the child process can only succeed when the command lookup is child-local. The parent test asserts the isolated probe actually ran and passed, so a filter that matches nothing cannot report a false success.

Scope: POSIX only, matching the existing fixture (/bin/sh, #[cfg(unix)]). The fixture already requires a POSIX layout; pinning the two standard system directories does not assume Nix or Homebrew layouts.

Validation

cargo test --locked -p webcodex-cli --lib controller_fixture
  -> 1 passed; 1 ignored; 545 filtered out

With the child-local PATH removed (change reverted), the same tests fail:
  fixture utility lookup failed: /bin/sh: line 1: sleep: command not found
  test result: FAILED. 0 passed; 1 failed; 1 ignored; 545 filtered out

The ignored probe is invoked explicitly by its parent test; it is not meant to run in the ordinary parallel pool. Not run here: macOS and Windows lanes (no environment available; the fixture is POSIX-only by construction).

The controller TUI fixture inherited the test process PATH, which other tests replace, so its external utility lookups failed non-deterministically. Pin a child-local PATH for the spawned shell and cover it with an isolated child-process regression that runs the fixture with a polluted inherited PATH.

@yyjeqhc yyjeqhc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the scoped implementation and regression coverage against its source baseline; CI and diff checks pass. No blocking issue identified.

@yyjeqhc
yyjeqhc merged commit cf65377 into yyjeqhc:main Oct 28, 2026
18 checks passed
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.

2 participants