From 66dbd29cd194a4c84f796f32827429895c2a3bba Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Sat, 19 Nov 2016 16:16:20 -0800 Subject: Add support for recording/running ref tests Ref tests use a recording of the terminal protocol and a serialization of the grid state to check that the parsing and action handling systems produce the correct result. Ref tests may be recorded by running alacritty with `--ref-test` and closing the terminal by using the window "X" button. At that point, the recording is fully written to disk, and a serialization of important state is recorded. Those files should be moved to an appropriate folder in the `tests/ref/` tree, and the `ref_test!` macro invocation should be updated accordingly. A couple of changes were necessary to make this work: * Ref tests shouldn't create a pty; the pty was refactored out of the `Term` type. * Repeatable lines/cols were needed; on startup, the terminal is resized * by default to 80x24 though that may be changed by passing `--dimensions w h`. * Calculating window size based on desired rows/columns and font metrics required making load_font callable multiple times. * Refactor types into library crate so they may be imported in an integration test. * A whole bunch of types needed symmetric serialization and deserialization. Mostly this was just adding derives, but the custom deserialization of Rgb had to change to a deserialize_with function. This initially adds one ref test as a sanity check, and more will be added in subsequent commits. This initial ref tests just starts the terminal and runs `ll`. --- src/index.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/index.rs') diff --git a/src/index.rs b/src/index.rs index 946e01fa..dc98be1e 100644 --- a/src/index.rs +++ b/src/index.rs @@ -21,7 +21,7 @@ use std::mem; use std::ops::{self, Deref, Add}; /// Index in the grid using row, column notation -#[derive(Debug, Clone, Default, Eq, PartialEq)] +#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct Cursor { pub line: Line, pub col: Column, @@ -30,7 +30,7 @@ pub struct Cursor { /// A line /// /// Newtype to avoid passing values incorrectly -#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Serialize, Deserialize)] pub struct Line(pub usize); impl fmt::Display for Line { @@ -42,7 +42,7 @@ impl fmt::Display for Line { /// A column /// /// Newtype to avoid passing values incorrectly -#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Serialize, Deserialize)] pub struct Column(pub usize); impl fmt::Display for Column { -- cgit v1.2.3-54-g00ecf