test: comprehensive shell passthrough test suite + extract into library#81
Merged
emal-avala merged 2 commits intomainfrom Apr 6, 2026
Merged
test: comprehensive shell passthrough test suite + extract into library#81emal-avala merged 2 commits intomainfrom
emal-avala merged 2 commits intomainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Extract shell passthrough logic from repl.rs into a testable library module at crates/lib/src/services/shell_passthrough.rs, then add tests at every level: Unit tests (25 tests in shell_passthrough.rs): - capture_lines: under limit, truncation, empty, single line, callback called after truncation, exact boundary behavior - build_context_message: header format, truncation suffix, empty returns None, multiline preservation, special characters - run_and_capture: stdout, stderr, mixed, multiline, empty command, exit codes, cwd respect, callbacks, truncation, invalid commands - Full pipeline: echo→message, empty→None, truncated→suffix Integration tests (11 tests in shell_passthrough_integration.rs): - Message system compatibility: valid UserMessage, alternation safe, serialization roundtrip - Subprocess integration: cwd respect, exit codes, binary output, 500-line capture, truncation preserves complete lines - Content format: header format, truncation suffix position, special character preservation E2E bash tests (4 tests in scripts/e2e-tests.sh section L): - L1: Tool output appears in /messages conversation history - L2: Multi-turn context retention with tool output - L3: Large output handling (1000 lines) - L4: stderr captured alongside stdout Refactor: repl.rs ! prefix handler now calls shell_passthrough module (19 lines vs 92 lines previously). Same behavior, fully testable.
9a96b71 to
a7ae627
Compare
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
Extracts shell passthrough logic into a testable library module and adds 40 tests across 3 layers.
What changed
New module:
crates/lib/src/services/shell_passthrough.rs(519 lines)Extracts the
!prefix logic fromrepl.rsinto reusable, testable functions:capture_lines()— reads from anyReadimpl, captures to buffer with 50KB limitrun_and_capture()— spawns bash subprocess, streams output, returnsCapturedOutputbuild_context_message()— buildsUserMessage(is_meta: true)from captured outputRefactored:
crates/cli/src/ui/repl.rs(92 lines → 19 lines)The
!handler now calls the library module. Same behavior, 73 fewer lines.Test coverage
25 unit tests (in
shell_passthrough.rs):capture_linesbuild_context_messagerun_and_capture11 integration tests (in
shell_passthrough_integration.rs):4 E2E bash tests (section L in
e2e-tests.sh):/messagesconversation historyTest results
Test plan
cargo fmt --all -- --check— cleancargo clippy -- -D warnings— zero warningscargo test— 621 tests pass (40 new)release-e2e.yml🤖 Generated with Claude Code