Repository navigation
refactor(tests): bring the mock-stub env vars under the WORKTRUNK_TEST_ prefix - #3621
Merged
Merged
Conversation
…T_ prefix `MOCK_CONFIG_DIR` and `MOCK_CALL_LOG_DIR` were the only two worktrunk-invented environment variables without the `WORKTRUNK_` prefix. That is not just a naming inconsistency: `isolate_subprocess_env` scrubs the parent environment by prefix — `GIT_*` and `WORKTRUNK_*` — so an unprefixed name is the one thing a test child inherits from whoever ran the suite. Renaming them to `WORKTRUNK_TEST_MOCK_CONFIG_DIR` and `WORKTRUNK_TEST_MOCK_CALL_LOG_DIR` brings them under that scrub. `TEST` rather than a bare `WORKTRUNK_` because both are read only by `tests/helpers/mock-stub` — they are the protocol between the harness and its helper binary, and `wt` itself never reads either one. That matches the ~15 existing `WORKTRUNK_TEST_*` knobs. The snapshot half is mechanical but not a substitution: the `env:` block is byte-sorted by key, so the renamed entry moves position within it. All 971 affected blocks were rewritten by dropping the old line, inserting the new one, and re-sorting; the diff is exactly one removed and one added line per file. The redaction that produces the placeholder follows its neighbours' convention (`WORKTRUNK_TEST_NU_VENDOR_AUTOLOAD_DIR` → `[TEST_NU_VENDOR_AUTOLOAD]`), so it now reads `[TEST_MOCK_CONFIG]`. `tests/CLAUDE.md` gains the rule under "Where a new environment variable goes", so the next helper-binary protocol variable is not named `MOCK_*` again. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 <[email protected]>
max-sixty
marked this pull request as ready for review
July 27, 2026 03:17
worktrunk-bot
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MOCK_CONFIG_DIRandMOCK_CALL_LOG_DIRwere the only two worktrunk-invented environment variables without theWORKTRUNK_prefix. That is not just a naming inconsistency:isolate_subprocess_envscrubs the parent environment by prefix —GIT_*andWORKTRUNK_*— so an unprefixed name is the one thing a test child inherits from whoever ran the suite. Renaming them brings them under that scrub.MOCK_CONFIG_DIR→WORKTRUNK_TEST_MOCK_CONFIG_DIRMOCK_CALL_LOG_DIR→WORKTRUNK_TEST_MOCK_CALL_LOG_DIRTESTrather than a bareWORKTRUNK_because both are read only bytests/helpers/mock-stub— they are the protocol between the harness and its helper binary, andwtitself never reads either one. That matches the ~15 existingWORKTRUNK_TEST_*knobs.The snapshot half
Mechanical but not a substitution: the
env:block is byte-sorted by key, so the renamed entry moves position within it and asedin place would leave it where the old name sorted. All 971 affected blocks were rewritten by dropping the old line, inserting the new one, and re-sorting — the aggregate diff is exactly one removed and one added line per file:The redaction placeholder follows its neighbours' convention in
add_standard_env_redactions(WORKTRUNK_TEST_NU_VENDOR_AUTOLOAD_DIR→[TEST_NU_VENDOR_AUTOLOAD]), so it now reads[TEST_MOCK_CONFIG]rather than repeating the full key.MOCK_CALL_LOG_DIRappears in no snapshot — its two call sites are.output()assertion tests — so it needs no redaction.Keeping it from regressing
tests/CLAUDE.mdgains the rule under "Where a new environment variable goes": name itWORKTRUNK_TEST_*, and the rule covers the harness↔helper-binary protocol, not just knobswtitself reads. Without it the next helper-binary variable gets namedMOCK_*again and the hermeticity hole reopens.Verification
cargo run -- hook pre-merge --yespasses (exit 0) on the merged tree: 4607 tests including--features shell-integration-tests,pre-commit run --all-files, clippy, doctests. No pending snapshots. A repo-wide sweep finds no remaining unprefixed spelling.Merged main
#3620 landed while this was in flight and regenerated several
for_eachsnapshots that still carried the old key, so main is merged in here. It resolved with no conflicts, and the result is what you'd want rather than what git happened to produce: those blocks now carry #3620's new keys (GIT_ALLOW_PROTOCOL,CLAUDE_CONFIG_DIR,WORKTRUNK_TEST_PARENT_SHELL) and the renamed key, each in sorted position. The sweep and the gate above both ran after the merge.#3620 also rewrote the "Where a new environment variable goes" section this branch adds to — three layers became four. Both edits survived; the new naming paragraph follows the updated layer list.
The two advisory
affected testschecks are red for the same reason, and merging clears them:cargo affectederrors ongit diff stdout was not valid UTF-8, because the diff from this PR's base contains 16 binary files — thetests/fixtures/standard/git objects and index files that #3620 deleted. This branch's own commit contributes none. A PR based after #3620 won't see them.🤖 Generated with Claude Code