CLI tests: verify sotto run overlays secrets onto the inherited environment
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start with run_with_entries in crates/cli/src/main.rs, which builds the child command and applies entries via Command::env, then read the existing subprocess tests near child_exit_status_helper to copy the isolation and bounded-wait pattern. Add helper-process tests that check inherited variables, same-name overrides, empty-string values, exact text round-trips, and that the override warning names the variable without its values. Done means the new tests pass on Unix and Windows and cargo fmt --all --check is clean.
Written by the indexing model from the issue text.
Description
The problem
sotto run overlays the selected environment's secrets onto the child process's inherited environment. The existing subprocess tests exercise exit-status propagation with an empty entries vector, so they do not protect the injection behaviour itself.
Add focused tests that observe the environment inside a real child process. This is a coverage gap, not a report that environment injection currently fails.
Evidence and starting points
Source-inspected on clean main at ee7ec8583dfe4e28ac08bbf456be2fb25fe8c359 on macOS:
run_with_entriescreates a command, validates each key and applies entries throughCommand::env. It preserves the inherited environment and warns when a supplied name already exists.- Both the local-session and machine-token paths use this helper.
- The subprocess tests show how to isolate the Unix process replacement / Windows process exit behaviour.
child_exit_status_helpercallsrun_with_entries(Vec::new(), argv).
No Rust tests were executed for this issue. Existing CLI tests and open/closed issues were searched for overlap. #725 / PR #729 covered exit statuses; #803 / PR #805 document inheritance and shell quoting. This task verifies environment overlay through the actual launch path.
Acceptance criteria
- Launch a helper process with a synthetic inherited variable that is not present in the injected entries; verify that the final child still receives it unchanged.
- Seed another synthetic inherited variable and inject the same name with a different value. Verify that the final child receives the injected value.
- Verify that an injected empty string replaces a non-empty inherited value and remains present as an empty variable, rather than being omitted.
- Verify exact preservation of representative text values, including spaces, quotes, a newline, non-ASCII text and literal dollar-sign text. Use structured output or child-side assertions so shell interpolation and line splitting cannot hide a mismatch.
- Assert that the override diagnostic identifies the overridden variable on stderr, without printing either its old or new value. Keep assertions focused on this diagnostic rather than requiring entirely empty stderr from the test harness.
- Exercise
run_with_entriesitself, not a separately reconstructedCommand. Run it only in an isolated helper process because it replaces or exits its process. Keep a bounded wait and clean up a timed-out child using the existing pattern. - Set inherited test variables on the helper's
Command, not through process-wide environment mutation in the parallel test runner. Use dedicated synthetic variable names; do not override PATH, HOME or other system settings.
Scope and validation
No real vault, network access, machine token or OS keychain is required: pass synthetic entries directly at the shared launch boundary. Do not change injection policy or add a shell wrapper to production code.
Use platform-appropriate fixtures so the tests can run on supported Unix and Windows CI. Run the focused tests and cargo fmt --all --check, and report which platform was actually tested locally. Existing exit-status tests should continue to pass.
Follow CONTRIBUTING.md, including DCO sign-off (git commit -s).
- Dominant language
- Rust
- Stars
- 31
- Forks
- 42
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 142
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsotto/sotto
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
good first issue help wanted test-coverage
Difficulty 2/5 3-5 days Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug CLI
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
HigherOrderCO/Bend#2120 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
KNXBench-Labs/KNXBench#47 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
software-mansion/pathfinder#3620 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day