test(shell): fix test on non posix shell#2495
Closed
hongqitai wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates a shell execution test in crates/tui/src/tools/shell/tests.rs to wrap the printf command inside sh -c. This ensures the command runs in a shell environment, which is necessary for evaluating the environment variables correctly. There are no review comments, and I have no additional feedback to provide.
Owner
|
Thanks @hongqitai — harvested this shell test portability fix into main for v0.8.49 in d88b2c3. Closing this PR as integrated and credited in the changelog. |
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
Test "codewhale_tui::tools::shell::tests::shell_execution_scrubs_parent_env_and_keeps_explicit_env" fail on non posix shell like fish.
Use "sh -c" run command to fix it.
Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-featurescargo test --workspace --all-featuresChecklist
Greptile Summary
This PR fixes a test failure on non-POSIX shells (e.g. fish) by wrapping the test command in
sh -c '...', ensuring the POSIX${VAR-default}parameter expansion syntax is always interpreted by a POSIX-compatible shell rather than the user's default shell.${VAR-default}expansion being understood by the ambient shell; wrapping insh -censures a POSIX interpreter regardless of the configured shell dispatcher.sh -cargument uses single quotes, which prevent the outer shell from reinterpreting the double-quoted format string and variable expansions inside.Confidence Score: 5/5
Safe to merge — it is a one-line test-only change with correct quoting and no impact on production code paths.
The change is confined to a single test, replaces a shell-specific invocation with a portable
sh -cwrapper, preserves the original test assertion, and introduces no new logic or risk.No files require special attention.
Important Files Changed
sh -c '...'so POSIX parameter expansion works on non-POSIX shells like fish. Quoting is correct and the test assertion logic is unchanged.Sequence Diagram
sequenceDiagram participant T as Test participant M as ShellManager participant OS as OS Shell (e.g. fish) participant SH as sh (POSIX) T->>M: execute_with_options_env("sh -c 'printf ...'") M->>OS: spawn with scrubbed env + explicit vars OS->>SH: "sh -c 'printf "%s\n%s\n" "${VAR-unset}" ...'" SH-->>OS: "unset\nexplicit-value\n" OS-->>M: stdout M-->>T: "ShellResult { stdout: "unset\nexplicit-value\n" }" T->>T: assert_eq!(result.stdout, "unset\nexplicit-value\n")Reviews (1): Last reviewed commit: "test(shell): fix test on non posix shell" | Re-trigger Greptile