aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-11-19 16:16:20 -0800
committerJoe Wilm <joe@jwilm.com>2016-11-19 21:34:11 -0800
commit66dbd29cd194a4c84f796f32827429895c2a3bba (patch)
tree5f5322cdae53d4fc295fe85f519192e9d38aab03 /src/lib.rs
parentd97996e19de6856c23c51d05ec10f10db41e309d (diff)
downloadalacritty-66dbd29cd194a4c84f796f32827429895c2a3bba.tar.gz
alacritty-66dbd29cd194a4c84f796f32827429895c2a3bba.zip
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`.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 00000000..8052ce07
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,98 @@
+// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//! Alacritty - The GPU Enhanced Terminal
+#![feature(question_mark)]
+#![feature(range_contains)]
+#![feature(inclusive_range_syntax)]
+#![feature(drop_types_in_const)]
+#![feature(unicode)]
+#![feature(step_trait)]
+#![feature(core_intrinsics)]
+#![allow(stable_features)] // lying about question_mark because 1.14.0 isn't released!
+
+#![feature(proc_macro)]
+
+#[macro_use]
+extern crate serde_derive;
+
+extern crate cgmath;
+extern crate copypasta;
+extern crate errno;
+extern crate font;
+extern crate glutin;
+extern crate libc;
+extern crate mio;
+extern crate notify;
+extern crate parking_lot;
+extern crate serde;
+extern crate serde_json;
+extern crate serde_yaml;
+extern crate vte;
+
+#[macro_use]
+extern crate bitflags;
+
+#[macro_use]
+pub mod macros;
+
+pub mod event;
+pub mod event_loop;
+pub mod index;
+pub mod input;
+pub mod meter;
+pub mod renderer;
+pub mod sync;
+pub mod term;
+pub mod tty;
+pub mod util;
+pub mod ansi;
+pub mod config;
+pub mod grid;
+
+use std::sync::Arc;
+use std::sync::atomic::{AtomicBool, Ordering};
+
+pub use grid::Grid;
+pub use term::Term;
+
+#[derive(Debug, Eq, PartialEq, Copy, Clone, Default, Serialize, Deserialize)]
+pub struct Rgb {
+ pub r: u8,
+ pub g: u8,
+ pub b: u8,
+}
+
+pub mod gl {
+ #![allow(non_upper_case_globals)]
+ include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
+}
+
+#[derive(Clone)]
+pub struct Flag(pub Arc<AtomicBool>);
+impl Flag {
+ pub fn new(initial_value: bool) -> Flag {
+ Flag(Arc::new(AtomicBool::new(initial_value)))
+ }
+
+ #[inline]
+ pub fn get(&self) -> bool {
+ self.0.load(Ordering::Acquire)
+ }
+
+ #[inline]
+ pub fn set(&self, value: bool) {
+ self.0.store(value, Ordering::Release)
+ }
+}