Skip to content

test(cli): isolate fixtures from inherited scan-path env vars - #647

Merged
junhoyeo merged 2 commits into
junhoyeo:mainfrom
crhan:contrib/test-isolation-extra-dirs
May 31, 2026
Merged

test(cli): isolate fixtures from inherited scan-path env vars#647
junhoyeo merged 2 commits into
junhoyeo:mainfrom
crhan:contrib/test-isolation-extra-dirs

Conversation

@crhan

@crhan crhan commented May 31, 2026

Copy link
Copy Markdown
Contributor

Problem

cmd_with_home sets HOME and the XDG dirs but leaves TOKSCALE_EXTRA_DIRS, TOKSCALE_HEADLESS_DIR and CODEX_HOME inherited from the developer's shell.

A contributor who uses tokscale to track their own usage — e.g. export TOKSCALE_EXTRA_DIRS=...:~/.codex/sessions — makes the codex scanner read real session data from inside the test fixtures. Fixture-count assertions then fail locally while passing on CI's clean env. Concretely:

test_models_group_by_workspace_model_surfaces_workspace_fields_for_codex
  left: 50   (real ~/.codex sessions leaked in)
 right: 1    (the lone fixture session)

Confirmed by toggling the var: with TOKSCALE_EXTRA_DIRS unset the test passes; with it set it fails — independent of any source change.

Fix

Clear the three inherited scan-path overrides (TOKSCALE_EXTRA_DIRS, TOKSCALE_HEADLESS_DIR, CODEX_HOME) in cmd_with_home so tests are hermetic regardless of the dev's shell. Tests that need CODEX_HOME set it explicitly afterwards, so the removal is overridden where intended.

Verification

  • The previously-failing test now passes with TOKSCALE_EXTRA_DIRS still exported in the shell.
  • Full cargo test -p tokscale-cli suite green (no regression in the CODEX_HOME-setting tests).

🤖 Generated with Claude Code


Summary by cubic

Make CLI tests hermetic by clearing inherited scan-path and tool-home env vars in cmd_with_home and offline_cmd_with_home. Prevents real Codex session data and other artifacts from leaking into fixtures and fixes local count assertions.

  • Bug Fixes
    • Remove these in both helpers: TOKSCALE_EXTRA_DIRS, TOKSCALE_HEADLESS_DIR, CODEX_HOME, COPILOT_OTEL_FILE_EXPORTER_PATH, GOOSE_PATH_ROOT, CODEBUFF_DATA_DIR, GEMINI_CLI_HOME, HERMES_HOME, TOKSCALE_CONFIG_DIR.
    • Tests that need CODEX_HOME set it explicitly; the previously failing fixture-count test now passes even with TOKSCALE_EXTRA_DIRS exported; full cargo test -p tokscale-cli remains green.

Written for commit 9a92278. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
tokscale Ignored Ignored Preview May 31, 2026 7:46pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

crhan and others added 2 commits June 1, 2026 04:33
cmd_with_home / cmd_with_home_hermetic set HOME and XDG dirs but left
TOKSCALE_EXTRA_DIRS, TOKSCALE_HEADLESS_DIR and CODEX_HOME inherited from
the developer's shell. A dev who exports e.g.
TOKSCALE_EXTRA_DIRS=~/.codex/sessions (for codefuse mirror tracking) makes
the codex scanner read real session data inside the fixtures, so
fixture-count assertions like
test_models_group_by_workspace_model_surfaces_workspace_fields_for_codex
fail (entries 50 vs 1) locally while passing on CI's clean env.

Clear those three scan-path overrides in both helpers so tests are
hermetic regardless of the dev's shell. Tests that need CODEX_HOME set it
explicitly afterwards, so the removal is overridden where intended.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@junhoyeo
junhoyeo force-pushed the contrib/test-isolation-extra-dirs branch from c8b29a1 to 9a92278 Compare May 31, 2026 19:46
@junhoyeo
junhoyeo merged commit 0c8878c into junhoyeo:main May 31, 2026
14 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