Repository navigation
Conversation
isolate_rtk, renamed from redirect_rtk_data next to isolate_git, clears the environment and keeps only what KEPT names: PATH, what the loader needs to start a tool installed outside the system directories, TMPDIR, the locale and the time zone with the data they load, and what rustup needs to find cargo, plus the system variables WINDOWS_KEPT names on Windows, where the profile variables are pinned into the scratch directory alongside HOME. Removing variables by name let everything else through. A test's fake tools are shell scripts, so SHELLOPTS=xtrace exported in a contributor's shell made silent_command_stays_silent fail on any host where /bin/sh is bash; BASHOPTS, BASH_ENV, POSIXLY_CORRECT, CDPATH and exported functions change them the same way. A native tool or git a test compares rtk's output with gets the same environment, through common::native_command and isolate_git, so a setting only the contributor's shell exports, such as RIPGREP_CONFIG_PATH or COLUMNS, reaches neither side. Tests drop the removals and pins the empty environment makes redundant, and the hook protocol test isolates the bash hook that runs rtk the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
📊 Automated PR Analysis
SummaryRewrites the test suite's rtk isolation helper (renamed Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Merged
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.
Summary
A spawned rtk in the test suite now starts from an empty environment and keeps only the variables
KEPTnames insrc/core/test_isolation/scratch.rs, instead of inheriting everything but a list of removed names.Removing variables by name let everything else through. The fake tools tests put on
PATHare shell scripts, soSHELLOPTS=xtraceexported in a contributor's shell makessilent_command_stays_silentandguard_fallback_emits_exactly_the_command_bytesfail on any host where/bin/shis bash;BASHOPTS,BASH_ENV,POSIXLY_CORRECT,CDPATHand exported functions change them the same way. #4154 hits this with its new fake tools.Changes
redirect_rtk_datais renamedisolate_rtk, next toisolate_git. It clears the environment and keeps what a child needs to run tools at all:PATH, the loader paths,TMPDIR, the locale and time zone with their data, rustup's toolchain, and on Windows the system variables inWINDOWS_KEPT. rtk's data, git configuration andHOMEare pinned into the scratch directory as before; on Windows the profile variables are pinned there too.common::native_command()for a nativegrep,rg,headorwc, andisolate_git()for git. WithRIPGREP_CONFIG_PATHpointing at--max-columns=150,bulky_rg_yields_token_savingsfails if only rtk's side is isolated.env_removeandRTK_TELEMETRY_DISABLEDlines the empty environment makes redundant, and the hook protocol test runs its bash hook throughcommon::isolate_rtkinstead of a hand-written list..claude/rules/cli-testing.mddescribes the new contract.No change to the rtk binary: everything touched is test code.
Test plan
cargo fmt --all,cargo clippy --all-targets,cargo test --all: clean, 4267 tests.SHELLOPTS=xtraceexported, withTMPDIRinside a git repository, withRTK_DB_PATHexported (never written to), and in a French locale.tests/isolate_rtk_test.rsrunsenv(cmd /D /C seton Windows) directly, throughrtk proxy, as a native tool and as an isolated git, and checks that nothing this process inherited and isolation dropped reaches the child, and that rtk's data path lies in the scratch directory. Removingenv_clear(), bypassing isolation inrtk_commandornative_command, revertingisolate_git, or keepingRTK_DB_PATHunpinned each fails it.a_child_keeps_none_of_the_shell_settingsfails ifSHELLOPTSis added toKEPT;every_variable_rtk_reads_is_redirected_for_a_childfails if a variable rtk reads, such asCODEX_HOME, is.x86_64-pc-windows-gnu; CI runs it.🤖 Generated with Claude Code