Skip to content

Refactor ninja_with_exit_code fixture to use NINJA_ENV instead of PATH #96

@coderabbitai

Description

@coderabbitai

Description

The ninja_with_exit_code fixture in tests/runner_tests.rs currently manipulates the global PATH environment variable to make a fake ninja executable available. This should be refactored to use the NINJA_ENV environment variable instead, mirroring the approach used in other test fixtures.

Context

This refactoring was suggested during the review of PR #89: #89 (comment)

Current Implementation

The fixture currently:

  • Saves and modifies the PATH environment variable
  • Prepends the fake ninja directory to PATH
  • Returns a cleanup closure that restores the original PATH

Proposed Change

The fixture should instead:

  • Use NINJA_ENV to point directly to the fake ninja executable
  • Save and restore the original NINJA_ENV value
  • Avoid PATH manipulation entirely

Benefits

  • Cleaner test isolation (no global PATH modification)
  • Consistency with other test fixtures in the codebase
  • More predictable test behaviour

Implementation Notes

  • The fixture is located at lines 34-56 in tests/runner_tests.rs
  • Should follow the same pattern as the run_respects_env_override_for_ninja test
  • Maintain the same return tuple structure (tempfile::TempDir, PathBuf, Cleanup)

Requested by: @leynos

Metadata

Metadata

Assignees

Labels

lowAin't annoying anyone but the QA department

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions