Skip to content

test(core): isolate fixtures from inherited scan roots - #917

Merged
junhoyeo merged 1 commit into
junhoyeo:mainfrom
Nanako0129:test-core-isolate-fixtures
Jul 18, 2026
Merged

test(core): isolate fixtures from inherited scan roots#917
junhoyeo merged 1 commit into
junhoyeo:mainfrom
Nanako0129:test-core-isolate-fixtures

Conversation

@Nanako0129

@Nanako0129 Nanako0129 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route pure scanner fixtures through explicit-home scanning so inherited client roots cannot change their inputs
  • clear unrelated extra, headless, and same-client sibling roots from tests that intentionally exercise another environment root, while preserving dedicated positive environment coverage
  • make scanner environment restoration panic-safe and run materialized parser fixtures through the existing no-environment strategy

This applies the same fixture-isolation principle as #647 to tokscale-core. Production scanning, parser behavior, cache formats, parser versions, and public APIs are unchanged.

Reproduction

With valid hostile roots supplied through HOME, XDG variables, TOKSCALE_CONFIG_DIR, TOKSCALE_EXTRA_DIRS, client-specific home variables, and TOKSCALE_HEADLESS_DIR, the pre-change default-parallel core suite reported:

test result: FAILED. 1191 passed; 27 failed; 1 ignored

A focused fixed-count fixture demonstrated the contamination directly:

test scanner::tests::test_scan_all_clients_codebuff_walks_all_three_channels_by_default ... FAILED
assertion `left == right` failed
  left: 4
 right: 3

After this change, the same hostile environment passes with the default parallel runner:

test result: ok. 1219 passed; 0 failed; 1 ignored

The remaining core integration test binaries also pass under that environment.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --locked --workspace --all-features -- -D warnings
  • cargo test --locked --workspace --all-features
  • cargo build --locked --release -p tokscale-cli
  • focused guard-unwind, Codebuff fixed-count, scanner-settings deduplication, and materialized Codex parser regressions
  • hostile-environment cargo test -p tokscale-core with the default parallel runner
  • git diff --check

Platform boundary

The local environment does not have a Windows Rust target or Windows runner, so the changed #[cfg(test)] modules were not cross-compiled or executed on Windows. The repository's Windows native checks compile release binaries only and do not compile Rust test modules; those checks therefore provide production compile coverage, not Windows test-code or runtime coverage.


Summary by cubic

Isolated tokscale-core test fixtures from inherited environment scan roots so env vars can’t alter test inputs. Tests now use explicit-home scanning with a panic-safe env guard; production scanning, parser behavior, caches, and public APIs are unchanged.

  • Bug Fixes
    • Route pure scanner fixtures through the no-environment strategy so inherited client roots can’t add or redirect files.
    • Clear unrelated env roots in env-specific tests (e.g. TOKSCALE_EXTRA_DIRS, TOKSCALE_HEADLESS_DIR) while preserving positive environment coverage.
    • Add EnvGuard to restore env vars on unwind and shadow the parser test helper to the no-env path to keep pricing/cache behavior. Hostile env run now passes: 1219 passed, 0 failed, 1 ignored.

Written for commit ee97d53. Summary will update on new commits.

Review in cubic

Core fixed-count scanner fixtures and materialized parser tests still used
the production env-aware entry points. Valid inherited client roots could add
files or redirect a fixture away from its TempDir, producing 27 failures in a
hostile default-parallel core run.

Route pure fixtures through the existing explicit-home strategy, clear only
unrelated sibling scan roots from env-specific scanner tests, and use a
panic-safe guard for the new environment isolation. Shadow the test parser
helper with the no-env strategy while preserving its pricing and cache paths.
Dedicated positive environment tests continue to exercise production root
resolution.

The hostile core suite now passes with 1219 tests passing and one ignored;
strict workspace Clippy and all-feature tests also pass.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 17, 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 Jul 17, 2026 11:36pm

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 2 files

Re-trigger cubic

@junhoyeo
junhoyeo merged commit a092948 into junhoyeo:main Jul 18, 2026
15 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