From 9a6a01a672bbe498557586852c164c30220f2e14 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 1 Nov 2022 08:38:44 -0600 Subject: [PATCH] Add script to build everything and run all tests --- examples/editor-test/src/main.rs | 16 +++------------- src/editor.rs | 22 ---------------------- test.sh | 8 ++++++++ 3 files changed, 11 insertions(+), 35 deletions(-) create mode 100755 test.sh diff --git a/examples/editor-test/src/main.rs b/examples/editor-test/src/main.rs index eaf299e..9bae758 100644 --- a/examples/editor-test/src/main.rs +++ b/examples/editor-test/src/main.rs @@ -2,7 +2,7 @@ use cosmic_text::{Action, Buffer, Color, Editor, FontSystem, Metrics, SwashCache}; use orbclient::{EventOption, Renderer, Window, WindowFlag}; -use std::{env, fs, process, thread, time::{Duration, Instant}}; +use std::{env, fs, process, time::Instant}; use unicode_segmentation::UnicodeSegmentation; fn redraw(window: &mut Window, editor: &mut Editor<'_>, swash_cache: &mut SwashCache) { @@ -154,19 +154,9 @@ fn main() { } if wrong == 0 { log::info!("All lines matched!"); + process::exit(0); } else { log::error!("{} lines did not match!", wrong); - } - - //TODO: make window not async? - loop { - for event in window.events() { - match event.to_option() { - EventOption::Quit(_) => process::exit(0), - _ => (), - } - } - - thread::sleep(Duration::from_millis(1)); + process::exit(1); } } diff --git a/src/editor.rs b/src/editor.rs index a17c4e4..cc0904b 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -252,11 +252,6 @@ impl<'a> Editor<'a> { } else { let line = &mut self.buffer.lines[self.cursor.line]; - println!("Before"); - for span in line.attrs_list().spans() { - println!("{:?}", span); - } - // Collect text after insertion as a line let after = line.split_off(self.cursor.index); @@ -269,11 +264,6 @@ impl<'a> Editor<'a> { // Append the text after insertion line.append(after); - println!("After"); - for span in line.attrs_list().spans() { - println!("{:?}", span); - } - self.cursor.index += character.len_utf8(); } }, @@ -289,11 +279,6 @@ impl<'a> Editor<'a> { if self.cursor.index > 0 { let line = &mut self.buffer.lines[self.cursor.line]; - println!("Before"); - for span in line.attrs_list().spans() { - println!("{:?}", span); - } - // Get text line after cursor let after = line.split_off(self.cursor.index); @@ -307,8 +292,6 @@ impl<'a> Editor<'a> { } } - println!("Move cursor {} to {}", self.cursor.index, prev_index); - self.cursor.index = prev_index; // Remove character @@ -316,11 +299,6 @@ impl<'a> Editor<'a> { // Add text after cursor line.append(after); - - println!("After"); - for span in line.attrs_list().spans() { - println!("{:?}", span); - } } else if self.cursor.line > 0 { let mut line_index = self.cursor.line; let old_line = self.buffer.lines.remove(line_index); diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..843f1f8 --- /dev/null +++ b/test.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -ex + +cargo doc +cargo test +cargo build --release --all +env RUST_LOG=editor_test=info target/release/editor-test