Adds tools/difftest: a Zig driver built against a copy of Ghostty 1.3.1's own src/terminal (Zig 0.15.2, set up under target/ by tools/difftest/setup.sh) and a Rust twin on ghostty-terminal, both printing a canonical dump of every scrollback/active row (cells, graphemes, styles, hyperlinks, row flags), cursor, modes, regions, tabstops and colors. A seeded generator produces escape-heavy streams (UTF-8/wide/combining/emoji, C0, CSI with edge params, SGR, modes, ESC, OSC, DCS, margins, insert/delete); `just difftest` runs it with Zig assertions on (ReleaseSafe vs debug Rust) and off (ReleaseFast vs production Rust), with minimizers and a triage script. Divergences found and fixed in Rust (each with a regression test): - ill-formed UTF-8 decoding follows the SIMD path a default Ghostty build uses (not Zig's scalar fallback) - PageList::erase_rows keeps Zig's row-flag behavior on regrow - grapheme move on wrap with left/right margins uses the original cell Upstream bugs found and deliberately NOT replicated (per the project rule): a stale cell pointer after page growth in Terminal.zig:482/539 that drops a grapheme, plus several Zig assertion failures/segfaults; documented with minimized repros in docs/rewrite/notes/difftest-DF.md. Final run: 390k cases across many geometries, 0 divergences (Zig-abort cases, ~0.1-0.5%, are not compared). Test Plan: - just difftest 20000 "1 2 3" - cargo test -p ghostty-terminal (regression tests)
19 lines
582 B
Rust
19 lines
582 B
Rust
//! Rust twin of the Zig driver: `difftest_rs <cols> <rows> <max_scrollback> <file>`.
|
|
use std::io::Write as _;
|
|
|
|
fn main() {
|
|
let a: Vec<String> = std::env::args().collect();
|
|
assert!(
|
|
a.len() == 5,
|
|
"usage: difftest_rs cols rows max_scrollback file"
|
|
);
|
|
let input = std::fs::read(&a[4]).expect("read input");
|
|
let out = ghostty_difftest::dump(
|
|
&input,
|
|
a[1].parse().expect("cols"),
|
|
a[2].parse().expect("rows"),
|
|
a[3].parse().expect("scrollback"),
|
|
);
|
|
std::io::stdout().write_all(out.as_bytes()).expect("write");
|
|
}
|