Skip to content

Commit 4c0b334

Browse files
committed
refactor(pty): Rename PTY testing for clarity
1 parent 3ddfd67 commit 4c0b334

19 files changed

Lines changed: 528 additions & 47 deletions

codex-rs/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ members = [
4343
"utils/tokenizer",
4444
"acp",
4545
"mock-acp-agent",
46-
"tui-integration-tests",
46+
"tui-pty-e2e",
4747
]
4848
resolver = "2"
4949

codex-rs/docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The workspace is organized into crate categories:
2828
| Patch System | `apply-patch` | Structured file modification |
2929
| MCP | `mcp-types`, `rmcp-client` | Model Context Protocol support |
3030
| ACP | `acp`, `mock-acp-agent` | Agent Context Protocol support |
31-
| Testing | `tui-integration-tests` | PTY-based black-box TUI testing |
31+
| Testing | `tui-pty-e2e` | PTY-based black-box TUI testing |
3232
| Utilities | `utils/*`, `async-utils`, `ansi-escape`, `feedback` | Helper libraries |
3333

3434
Key architectural patterns:

codex-rs/mock-acp-agent/docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Path: @/codex-rs/mock-acp-agent
1111
### How it fits into the larger codebase
1212

1313
- Used by integration tests in `@/codex-rs/acp/tests/integration.rs` to test ACP protocol flow
14-
- Used by TUI black-box tests in `@/codex-rs/tui-integration-tests` as the `--model mock-acp-agent` backend
14+
- Used by TUI black-box tests in `@/codex-rs/tui-pty-e2e` as the `--model mock-acp-agent` backend
1515
- Enables end-to-end testing of `AgentProcess` without requiring real AI providers
1616
- Produces diagnostic stderr output that tests use to verify stderr capture functionality
1717
- Not shipped in production; exists solely for development and CI testing
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "tui-integration-tests"
2+
name = "tui-pty-e2e"
33
version = "0.1.0"
44
edition = "2021"
55

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Noridoc: TUI Integration Tests
22

3-
Path: @/codex-rs/tui-integration-tests
3+
Path: @/codex-rs/tui-pty-e2e
44

55
### Overview
66

@@ -19,7 +19,7 @@ Path: @/codex-rs/tui-integration-tests
1919

2020
### Core Implementation
2121

22-
**Test Harness:** `TuiSession` in `@/codex-rs/tui-integration-tests/src/lib.rs`
22+
**Test Harness:** `TuiSession` in `@/codex-rs/tui-pty-e2e/src/lib.rs`
2323

2424
The main API provides:
2525
- `spawn(rows, cols)` - Launch codex binary with mock-acp-agent in PTY with automatic temp directory
@@ -86,7 +86,7 @@ Screen State ACP registry lookup → mock-acp provider
8686
mock_acp_agent (env var configured)
8787
```
8888

89-
**Key Input Handling:** `Key` enum in `@/codex-rs/tui-integration-tests/src/keys.rs`
89+
**Key Input Handling:** `Key` enum in `@/codex-rs/tui-pty-e2e/src/keys.rs`
9090

9191
Converts high-level key events to ANSI escape sequences:
9292
- `Key::Enter``\r`
@@ -95,7 +95,7 @@ Converts high-level key events to ANSI escape sequences:
9595
- `Key::Backspace``\x7f`
9696
- `Key::Ctrl('c')` → Control character encoding
9797

98-
**Session Configuration:** `SessionConfig` in `@/codex-rs/tui-integration-tests/src/lib.rs`
98+
**Session Configuration:** `SessionConfig` in `@/codex-rs/tui-pty-e2e/src/lib.rs`
9999

100100
Builder pattern for test environment setup:
101101
- `model` field - Model name to use (defaults to `"mock-model"` which resolves to mock-acp-agent via ACP registry)
@@ -138,18 +138,18 @@ This delay allows the PTY subprocess time to process input and update the displa
138138

139139
| File | Coverage |
140140
|------|----------|
141-
| `@/codex-rs/tui-integration-tests/tests/startup.rs` | TUI initialization, prompt display, trust screen skipping, snapshot testing for 4 startup scenarios, non-blocking PTY verification |
142-
| `@/codex-rs/tui-integration-tests/tests/prompt_flow.rs` | Prompt submission and agent responses |
143-
| `@/codex-rs/tui-integration-tests/tests/input_handling.rs` | Text editing, backspace, Ctrl-C clearing, arrow key navigation with snapshot testing |
144-
| `@/codex-rs/tui-integration-tests/tests/streaming.rs` | Prompt submission with timing delays, agent response streaming |
141+
| `@/codex-rs/tui-pty-e2e/tests/startup.rs` | TUI initialization, prompt display, trust screen skipping, snapshot testing for 4 startup scenarios, non-blocking PTY verification |
142+
| `@/codex-rs/tui-pty-e2e/tests/prompt_flow.rs` | Prompt submission and agent responses |
143+
| `@/codex-rs/tui-pty-e2e/tests/input_handling.rs` | Text editing, backspace, Ctrl-C clearing, arrow key navigation with snapshot testing |
144+
| `@/codex-rs/tui-pty-e2e/tests/streaming.rs` | Prompt submission with timing delays, agent response streaming |
145145

146146
**Snapshot Files:**
147147

148148
| File | Test Coverage |
149149
|------|---------------|
150-
| `@/codex-rs/tui-integration-tests/tests/snapshots/startup__*.snap` | Various startup screen scenarios (welcome, dimensions, temp directory, trust screen) |
151-
| `@/codex-rs/tui-integration-tests/tests/snapshots/input_handling__*.snap` | Input handling scenarios (ctrl-c clear, typing/backspace, model changed) |
152-
| `@/codex-rs/tui-integration-tests/tests/snapshots/streaming__submit_input.snap` | Prompt submission and streaming response |
150+
| `@/codex-rs/tui-pty-e2e/tests/snapshots/startup__*.snap` | Various startup screen scenarios (welcome, dimensions, temp directory, trust screen) |
151+
| `@/codex-rs/tui-pty-e2e/tests/snapshots/input_handling__*.snap` | Input handling scenarios (ctrl-c clear, typing/backspace, model changed) |
152+
| `@/codex-rs/tui-pty-e2e/tests/snapshots/streaming__submit_input.snap` | Prompt submission and streaming response |
153153

154154
**Snapshot Testing with Insta:**
155155

@@ -158,19 +158,19 @@ Tests use `insta::assert_snapshot!()` to capture terminal output for visual regr
158158
assert_snapshot!("startup_screen", normalize_for_snapshot(session.screen_contents()));
159159
```
160160

161-
Snapshots stored in `@/codex-rs/tui-integration-tests/tests/snapshots/*.snap` for regression detection. Each snapshot captures the exact terminal output state at a specific test point.
161+
Snapshots stored in `@/codex-rs/tui-pty-e2e/tests/snapshots/*.snap` for regression detection. Each snapshot captures the exact terminal output state at a specific test point.
162162

163163
**Snapshot Normalization:**
164164

165-
The `normalize_for_snapshot()` helper function exported from `@/codex-rs/tui-integration-tests/src/lib.rs` ensures stable snapshots across test runs by replacing dynamic content:
165+
The `normalize_for_snapshot()` helper function exported from `@/codex-rs/tui-pty-e2e/src/lib.rs` ensures stable snapshots across test runs by replacing dynamic content:
166166

167167
Normalization rules:
168168
1. Temp directory paths (`/tmp/.tmpXXXXXX`) → `[TMP_DIR]` placeholder
169169
2. Random default prompts on lines starting with ```[DEFAULT_PROMPT]` placeholder
170170
- Detects specific default prompt patterns: "Find and fix a bug", "Explain this codebase", "Write tests for", etc.
171171
- Preserves user-entered prompts and UI text like "? for shortcuts"
172172

173-
Implementation in `@/codex-rs/tui-integration-tests/src/lib.rs:456-488`:
173+
Implementation in `@/codex-rs/tui-pty-e2e/src/lib.rs:456-488`:
174174
```rust
175175
pub fn normalize_for_snapshot(contents: String) -> String {
176176
// Replace /tmp/.tmpXXXXXX with [TMP_DIR]
@@ -179,7 +179,7 @@ pub fn normalize_for_snapshot(contents: String) -> String {
179179
}
180180
```
181181

182-
This normalization allows snapshot assertions to focus on UI structure and static content rather than ephemeral runtime values. All tests import and use this function consistently: `use tui_integration_tests::{normalize_for_snapshot, ...};`
182+
This normalization allows snapshot assertions to focus on UI structure and static content rather than ephemeral runtime values. All tests import and use this function consistently: `use tui_pty_e2e::{normalize_for_snapshot, ...};`
183183

184184
**PTY Implementation Details:**
185185

File renamed without changes.

0 commit comments

Comments
 (0)