test(compatibility): bandwhich + various fish things

This commit is contained in:
Aram Drevekenin 2020-09-29 11:40:47 +02:00
parent 71d527069a
commit cf1080bc3f
74 changed files with 376 additions and 171 deletions

View file

@ -6,7 +6,7 @@ use ::std::collections::HashMap;
use ::std::sync::{Arc, Mutex};
use crate::os_input_output::OsApi;
use crate::tests::possible_inputs::{Bytes, get_possible_inputs};
use crate::tests::possible_tty_inputs::{Bytes, get_possible_tty_inputs};
#[derive(Clone)]
pub enum IoEvent {
@ -74,7 +74,7 @@ pub struct FakeInputOutput {
pub stdout_writer: FakeStdoutWriter, // stdout_writer.output is already an arc/mutex
io_events: Arc<Mutex<Vec<IoEvent>>>,
win_sizes: Arc<Mutex<HashMap<RawFd, Winsize>>>,
possible_inputs: HashMap<u16, Bytes>,
possible_tty_inputs: HashMap<u16, Bytes>,
}
impl FakeInputOutput {
@ -88,9 +88,13 @@ impl FakeInputOutput {
stdout_writer: FakeStdoutWriter::default(),
io_events: Arc::new(Mutex::new(vec![])),
win_sizes: Arc::new(Mutex::new(win_sizes)),
possible_inputs: get_possible_inputs(),
possible_tty_inputs: get_possible_tty_inputs(),
}
}
pub fn with_tty_inputs(mut self, tty_inputs: HashMap<u16, Bytes>) -> Self {
self.possible_tty_inputs = tty_inputs;
self
}
pub fn add_terminal_input(&mut self, input: &[u8]) {
self.input_to_add = Arc::new(Mutex::new(Some(input.to_vec())));
}
@ -106,7 +110,7 @@ impl OsApi for FakeInputOutput {
*winsize
}
fn set_terminal_size_using_fd(&mut self, pid: RawFd, cols: u16, rows: u16) {
let terminal_input = self.possible_inputs.get(&cols).expect(&format!("could not find input for size {:?}", cols));
let terminal_input = self.possible_tty_inputs.get(&cols).expect(&format!("could not find input for size {:?}", cols));
self.read_buffers.lock().unwrap().insert(pid, terminal_input.clone());
self.io_events.lock().unwrap().push(IoEvent::SetTerminalSizeUsingFd(pid, cols, rows));
}

BIN
src/tests/fixtures/fish_and_bandwhich vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,8 +1,9 @@
use ::nix::pty::Winsize;
use ::insta::assert_snapshot;
use crate::{start, TerminalOutput};
use crate::start;
use crate::tests::fakes::{FakeInputOutput};
use crate::tests::utils::get_output_frame_snapshots;
fn get_fake_os_input (fake_win_size: &Winsize) -> FakeInputOutput {
FakeInputOutput::new(fake_win_size.clone())
@ -19,33 +20,9 @@ pub fn starts_with_one_terminal () {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q)
start(Box::new(fake_input_output.clone()));
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
let mut vte_parser = vte::Parser::new();
let main_pid = 0;
let x = 0;
let y = 0;
let mut terminal_output = TerminalOutput::new(main_pid, fake_win_size, x, y);
for frame in output_frames.iter() {
for byte in frame.iter() {
vte_parser.advance(&mut terminal_output, *byte);
}
let output_lines = terminal_output.read_buffer_as_lines();
let cursor_position_in_last_line = terminal_output.cursor_position_in_last_line();
let mut snapshot = String::new();
for (line_index, line) in output_lines.iter().enumerate() {
for (character_index, terminal_character) in line.iter().enumerate() {
if line_index == output_lines.len() - 1 && character_index == cursor_position_in_last_line {
snapshot.push('█');
} else {
snapshot.push(terminal_character.character);
}
}
if line_index != output_lines.len() - 1 {
snapshot.push('\n');
}
}
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
for snapshot in snapshots {
assert_snapshot!(snapshot);
}
}
@ -61,33 +38,9 @@ pub fn split_terminals_vertically() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[14, 17]); // split-vertically and quit (ctrl-n + ctrl-q)
start(Box::new(fake_input_output.clone()));
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
let mut vte_parser = vte::Parser::new();
let main_pid = 0;
let x = 0;
let y = 0;
let mut terminal_output = TerminalOutput::new(main_pid, fake_win_size, x, y);
for frame in output_frames.iter() {
for byte in frame.iter() {
vte_parser.advance(&mut terminal_output, *byte);
}
let output_lines = terminal_output.read_buffer_as_lines();
let cursor_position_in_last_line = terminal_output.cursor_position_in_last_line();
let mut snapshot = String::new();
for (line_index, line) in output_lines.iter().enumerate() {
for (character_index, terminal_character) in line.iter().enumerate() {
if line_index == output_lines.len() - 1 && character_index == cursor_position_in_last_line {
snapshot.push('█');
} else {
snapshot.push(terminal_character.character);
}
}
if line_index != output_lines.len() - 1 {
snapshot.push('\n');
}
}
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
for snapshot in snapshots {
assert_snapshot!(snapshot);
}
}
@ -103,33 +56,9 @@ pub fn split_terminals_horizontally() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[2, 17]); // split-horizontally and quit (ctrl-b + ctrl-q)
start(Box::new(fake_input_output.clone()));
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
let mut vte_parser = vte::Parser::new();
let main_pid = 0;
let x = 0;
let y = 0;
let mut terminal_output = TerminalOutput::new(main_pid, fake_win_size, x, y);
for frame in output_frames.iter() {
for byte in frame.iter() {
vte_parser.advance(&mut terminal_output, *byte);
}
let output_lines = terminal_output.read_buffer_as_lines();
let cursor_position_in_last_line = terminal_output.cursor_position_in_last_line();
let mut snapshot = String::new();
for (line_index, line) in output_lines.iter().enumerate() {
for (character_index, terminal_character) in line.iter().enumerate() {
if line_index == output_lines.len() - 1 && character_index == cursor_position_in_last_line {
snapshot.push('█');
} else {
snapshot.push(terminal_character.character);
}
}
if line_index != output_lines.len() - 1 {
snapshot.push('\n');
}
}
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
for snapshot in snapshots {
assert_snapshot!(snapshot);
}
}
@ -163,34 +92,9 @@ pub fn resize_right_and_up_on_the_same_axis() {
fake_input_output.add_terminal_input(&[2, 14, 16, 14, 16, 16, 12, 8, 11, 17]);
start(Box::new(fake_input_output.clone()));
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
let mut vte_parser = vte::Parser::new();
let main_pid = 0;
let x = 0;
let y = 0;
let mut terminal_output = TerminalOutput::new(main_pid, fake_win_size, x, y);
for frame in output_frames.iter() {
for byte in frame.iter() {
vte_parser.advance(&mut terminal_output, *byte);
}
let output_lines = terminal_output.read_buffer_as_lines();
let (cursor_x, cursor_y) = terminal_output.cursor_coordinates();
let mut snapshot = String::new();
for (line_index, line) in output_lines.iter().enumerate() {
for (character_index, terminal_character) in line.iter().enumerate() {
if line_index == cursor_y - 1 && character_index == cursor_x {
snapshot.push('█');
} else {
snapshot.push(terminal_character.character);
}
}
if line_index != output_lines.len() - 1 {
snapshot.push('\n');
}
}
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
for snapshot in snapshots {
assert_snapshot!(snapshot);
}
}

View file

@ -0,0 +1,90 @@
use ::nix::pty::Winsize;
use ::insta::assert_snapshot;
use ::std::collections::HashMap;
use crate::start;
use crate::tests::possible_tty_inputs::Bytes;
use crate::tests::fakes::{FakeInputOutput};
use crate::tests::utils::get_output_frame_snapshots;
/*
* These tests are general compatibility tests for non-trivial scenarios running in the terminal.
* They use fake TTY input replicated from these scenarios (and so don't actually interact with the
* OS).
*
* They work like this:
* - receive fake TTY input containing various VTE instructions.
* - run that output through mosaic so it interprets it and creates its state based on it
* - read that state into a Human-readable snapshot and compare it to the expected snapshot for
* this scenario.
*
*/
fn get_fake_os_input (fake_win_size: &Winsize, fixture_name: &str) -> FakeInputOutput {
let mut tty_inputs = HashMap::new();
let fixture_bytes = Bytes::from_file_in_fixtures(&fixture_name);
tty_inputs.insert(fake_win_size.ws_col, fixture_bytes);
FakeInputOutput::new(fake_win_size.clone()).with_tty_inputs(tty_inputs)
}
#[test]
pub fn run_bandwhich_from_fish_shell() {
let fake_win_size = Winsize {
ws_col: 116,
ws_row: 28,
ws_xpixel: 0,
ws_ypixel: 0,
};
let fixture_name = "fish_and_bandwhich";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q)
start(Box::new(fake_input_output.clone()));
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
for snapshot in snapshots {
assert_snapshot!(snapshot);
}
}
#[test]
pub fn fish_tab_completion_options() {
let fake_win_size = Winsize {
ws_col: 116,
ws_row: 28,
ws_xpixel: 0,
ws_ypixel: 0,
};
let fixture_name = "fish_tab_completion_options";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q)
start(Box::new(fake_input_output.clone()));
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
for snapshot in snapshots {
assert_snapshot!(snapshot);
}
}
#[test]
pub fn fish_select_tab_completion_options() {
// the difference between this and the previous test is that here we press <TAB>
// twice, meaning the selection moves between the options and the command line
// changes.
// this is not clearly seen in the snapshot because it does not include styles,
// but we can see the command line change and the cursor staying in place
let fake_win_size = Winsize {
ws_col: 116,
ws_row: 28,
ws_xpixel: 0,
ws_ypixel: 0,
};
let fixture_name = "fish_select_tab_completion_options";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[17]); // quit (ctrl-q)
start(Box::new(fake_input_output.clone()));
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
for snapshot in snapshots {
assert_snapshot!(snapshot);
}
}

View file

@ -1,4 +1,5 @@
pub mod basic;
pub mod compatibility;
pub mod resize_right;
pub mod resize_left;
pub mod resize_up;

View file

@ -0,0 +1,32 @@
---
source: src/tests/integration/compatibility.rs
expression: snapshot
---
Welcome to fish, the friendly interactive shell
⋊> ~/c/mosaic on main sudo badblock 11:32:233
badblocks (Executable, 33kB) base64 (Executable, 42kB) bash (Executable, 906kB)
bandwhich (Executable, 3.0MB) basename (Executable, 38kB) bashbug (Executable, 6.8kB)
base32 (Executable, 42kB) basenc (Executable, 50kB) bass
Bye from Mosaic!█

View file

@ -0,0 +1,32 @@
---
source: src/tests/integration/compatibility.rs
expression: snapshot
---
Welcome to fish, the friendly interactive shell
⋊> ~/c/mosaic on main sudo badblock █ 11:32:233
badblocks (Executable, 33kB) base64 (Executable, 42kB) bash (Executable, 906kB)
bandwhich (Executable, 3.0MB) basename (Executable, 38kB) bashbug (Executable, 6.8kB)
base32 (Executable, 42kB) basenc (Executable, 50kB) bass

View file

@ -0,0 +1,32 @@
---
source: src/tests/integration/compatibility.rs
expression: snapshot
---
Welcome to fish, the friendly interactive shell
⋊> ~/c/mosaic on main sudo bandwhich 11:18:26
badblocks (Executable, 33kB) base64 (Executable, 42kB) bash (Executable, 906kB)
bandwhich (Executable, 3.0MB) basename (Executable, 38kB) bashbug (Executable, 6.8kB)
base32 (Executable, 42kB) basenc (Executable, 50kB) bass
Bye from Mosaic!█

View file

@ -0,0 +1,32 @@
---
source: src/tests/integration/compatibility.rs
expression: snapshot
---
Welcome to fish, the friendly interactive shell
⋊> ~/c/mosaic on main sudo ba█dwhich 11:18:26
badblocks (Executable, 33kB) base64 (Executable, 42kB) bash (Executable, 906kB)
bandwhich (Executable, 3.0MB) basename (Executable, 38kB) bashbug (Executable, 6.8kB)
base32 (Executable, 42kB) basenc (Executable, 50kB) bass

View file

@ -0,0 +1,32 @@
---
source: src/tests/integration/compatibility.rs
expression: snapshot
---
┌Utilization by process name───────────────────────────────────────────────────────────────────────────────────────┐
│Process Connections Up / Down │
│ │
│firefox 3 46Bps / 57Bps │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).
Bye from Mosaic!█

View file

@ -0,0 +1,32 @@
---
source: src/tests/integration/compatibility.rs
expression: snapshot
---
Total Up / Down: 46Bps / 57Bps
┌Utilization by process name───────────────────────────────────────────────────────────────────────────────────────┐
│Process Connections Up / Down │
│ │
│firefox 3 46Bps / 5█Bps │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).

View file

@ -21,4 +21,4 @@ prompt $ │line15-bbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -41,4 +41,4 @@ prompt $ │
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │line15-bbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -41,4 +41,4 @@ prompt $ │
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │line10-bbbbbbbbbb
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -31,7 +31,7 @@ prompt $ │line12-bbbbbbbbbb
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line12-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
a │line13-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View file

@ -31,7 +31,7 @@ prompt $ │line16-bbbbbbbbbb
────────────────────────────────────────────────────────────│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line12-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
a │line13-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │line10-bbbbbbbbbb
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -31,7 +31,7 @@ prompt $ │line12-bbbbbbbbbb
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line12-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
a │line13-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View file

@ -31,7 +31,7 @@ prompt $ │line16-bbbbbbbbbb
────────────────────────────────────────────────────────────│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line12-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
a │line13-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │line15-bbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -41,4 +41,4 @@ prompt $ │
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │line15-bbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -41,4 +41,4 @@ prompt $ │
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line17-bbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line18-bbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│line19-bbbbbbbbbbbbbbbbbbbbbb
│prompt $ │prompt $
│prompt $ │prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -21,4 +21,4 @@ prompt $ │prompt $
│line17-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line18-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│line19-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
│prompt $
│prompt $

View file

@ -1,5 +1,5 @@
pub mod integration;
pub mod possible_inputs;
pub mod possible_tty_inputs;
pub mod tty_inputs;
pub mod fakes;
pub mod utils;

View file

@ -1,4 +1,6 @@
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
use crate::tests::tty_inputs::{COL_10, COL_60, COL_14, COL_19, COL_20, COL_24, COL_29, COL_30, COL_34, COL_39, COL_40, COL_50, COL_70, COL_121};
#[derive(Clone, Debug)]
@ -14,6 +16,18 @@ impl Bytes {
read_position: 0
}
}
pub fn from_file_in_fixtures(file_name: &str) -> Self {
let mut path_to_file = PathBuf::new();
path_to_file.push("src");
path_to_file.push("tests");
path_to_file.push("fixtures");
path_to_file.push(file_name);
let content = fs::read(path_to_file).expect(&format!("could not read fixture {:?}", &file_name));
Bytes {
content,
read_position: 0
}
}
pub fn content(mut self, content: Vec<u8>) -> Self {
self.content = content;
self
@ -33,7 +47,7 @@ impl Bytes {
}
}
pub fn get_possible_inputs () -> HashMap<u16, Bytes> { // the key is the column count for this terminal input
pub fn get_possible_tty_inputs () -> HashMap<u16, Bytes> { // the key is the column count for this terminal input
let mut possible_inputs = HashMap::new();
let col_10_bytes = Bytes::new().content_from_str(&COL_10);
let col_14_bytes = Bytes::new().content_from_str(&COL_14);

View file

@ -18,7 +18,7 @@ pub fn get_output_frame_snapshots(output_frames: &[Vec<u8>], win_size: &Winsize)
let mut snapshot = String::new();
for (line_index, line) in output_lines.iter().enumerate() {
for (character_index, terminal_character) in line.iter().enumerate() {
if line_index == cursor_y - 1 && character_index == cursor_x {
if line_index == cursor_y && character_index == cursor_x {
snapshot.push('█');
} else {
snapshot.push(terminal_character.character);