VT

vyncint/termlens

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

27 stars 품질 60 트렌드 31Apache-2.0

Rust의 CLI 및 TUI 앱에 대한 헤드리스 엔드 투 엔드 테스트 : 실제 PTY, 렌더링 스크린 assertions, 스냅 샷 및 스크린 디퓨즈.

개요

termlens는 실제적인 의사 결정에 있는 당신의 진짜 이진을 떠납니다, in-memory 스크린 격자로 VT 에뮬레이터를 통해서 그것의 산출을 렌더링하고, 시험 대기를, 격자에 대하여 주장하고 스냅샷을 잡으십시오 — 사용자가 그것을 생성한 바이트가 아닙니다. Ratatui의 snapshot-testing 요리법에는 PTY를 통해 컴파일 된 응용 프로그램을 테스트하기위한 termlens 예제가 포함되어 있습니다. TestBackend 스냅샷을 사용하여 상호 작용과 프로세스 행동을 다룹니다. in-process 위젯 테스트는 버퍼로 draw 함수를 렌더링합니다. 빠르고 정확하며, 그리기와 사용자의 눈 사이에 아무것도 볼 수 없습니다. termlens 은 두 번째 층, 의 작은 숫자 끝에서 마지막 흐름을 통해 실제 바이너리: - — 원시 모드 및 교체 화면 입력 및 왼쪽, 큐서는 q 또는 공황 후 복원, 모드는 응용 프로그램 켜고 그 자리에 설정. -- 상자 그림, 색깔, 넓은 특성, 명확한, stray println에서 인쇄되지 않는 암호 분야!

개요(AI 번역)

** 터미널 프로그램에 대한 통합 테스트, 웹을 테스트 할 수있는 방법 app.** termlens는 실제적인 의사 결정에 있는 당신의 진짜 바이너리를 spawns, 렌더링합니다 VT emulator를 in-memory 화면 격자로 출력하고, 테스트 대기, assert against and snapshot that grid — 사용자가 see는, 그것을 생성한 바이트 아닙니다.

Ratatui의 snapshot-testing 조리법 PTY를 통해 컴파일 된 응용 프로그램을 테스트하기위한 용어 예제가 포함되어 있습니다. TestBackend] 스냅샷을 사용하여 상호 작용 및 프로세스를 처리 행동.

왜

in-process 위젯 테스트는 버퍼로 draw 함수를 렌더링합니다. 그것은 빠르고 정확하며, draw과 사용자의 사이에서 아무것도 볼 수 없습니다. 눈. termlens는 두 번째 층, 작은 숫자의 끝에 흐름 실제 바이너리를 통해:

  • Terminal state - 원시 모드 및 교체 화면 입력 및 왼쪽, cursor는 q 또는 공황 후 복원, 모드는 응용 프로그램 설정 그대는 그대를 돌리며
  • ** 실제로 그려진 ** - 상자 그림, 색상, 넓은 문자, concealed는 명확하게, stray에서 인쇄한 보다는 오히려 입니다

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

termlens

Integration testing for terminal programs, the way you would test a web app. termlens spawns your real binary in a real pseudo-terminal, renders its output through a VT emulator into an in-memory screen grid, and lets a test wait on, assert against and snapshot that grid — what a user would see, not the bytes that produced it.

Ratatui’s snapshot-testing recipe includes a termlens example for testing a compiled application through a PTY. Use it alongside TestBackend snapshots to cover interactions and process behaviour.

Why

An in-process widget test renders your draw function into a buffer. It is fast and precise, and it cannot see anything between draw and the user’s eyes. termlens is the second layer, for a small number of end-to-end flows through the real binary:

  • Terminal state — raw mode and the alternate screen entered and left, the cursor restored after q or a panic, the modes the application turned on and whether it turned them off.
  • What is actually drawn — box drawing, colours, wide characters, a password field that is concealed rather than printed in clear, a stray println! or panic message that never went through the framework.
  • Real input and real signals — keys, mouse and paste encoded exactly as the terminal encodes them under the modes the application enabled; a SIGWINCH that the application must survive.
  • Behaviour that changes no cell — a repaint that drew nothing, a bell on a rejected key, an image that went out as pixels when it should have been text.

Every wait is deadline-bounded, and every failure carries the screen: a CI log shows what the application was displaying, not assertion failed: false.

Quick start

cargo add termlens --dev
cargo add insta --dev    # used by the snapshot assertions below
use std::time::Duration;
use termlens::{Key, Terminal};

#[test]
fn quits_from_the_main_screen() -> termlens::Result {
    let mut t = Terminal::builder()
        .size(80, 24)
        .env_clear()                       // hermetic: no host env leaks in
        .timeout(Duration::from_secs(5))   // every wait_* has this deadline
        .spawn(env!("CARGO_BIN_EXE_myapp"))?;

    // Wait for the app's ready marker, let the picture settle, then snapshot
    // it with its styles — the three decisions every TUI snapshot needs.
    termlens::assert_screen_snapshot!(t, after = |s| s.contains("Ready"));
GitHub에서 전체 README 보기

추천 도구

다른 키워드를 입력하거나 필터를 제거해 보세요.

설치

npx skillfish add vyncint/termlens
MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →