Skip to content

Add PTY-based terminal integration tests #104

@evansenter

Description

@evansenter

Problem

The REPL's terminal interaction (reedline integration, raw mode handling, output formatting) is currently untested. This led to a stairstepping bug in PR #102 that wasn't caught until manual testing.

Proposed Solution

Add integration tests using a PTY (pseudo-terminal) library to test actual terminal behavior:

#[test]
fn test_repl_output_no_stairstepping() {
    let mut pty = PtySession::spawn("clemini").unwrap();
    pty.send_line("What is 2+2?").unwrap();
    let output = pty.read_until_prompt().unwrap();
    
    // Each line should start at column 0 (no stairstepping)
    for line in output.lines().skip(1) { // Skip prompt line
        assert!(
            !line.starts_with(' ') || is_intentional_indent(line),
            "Stairstepping detected: {:?}",
            line
        );
    }
}

Libraries to Consider

  • expectrl - Rust expect-like library, good for REPL testing
  • portable-pty - Cross-platform PTY support
  • rexpect - Another expect-style library

Test Cases

  1. No stairstepping - Output lines start at column 0
  2. Ctrl-C handling - Returns to prompt cleanly
  3. History persistence - Commands saved and searchable
  4. Multiline input - Shift+Enter creates newlines (may need special key sequence)

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions