diff options
author | Christian Duerr <contact@christianduerr.com> | 2018-04-14 17:21:48 +0200 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:56:50 -0700 |
commit | 2234234ca9a2ab0d7eccd46893cbe6799b051aba (patch) | |
tree | 369d5a5b9855b7f3c08d5f8a3836ed9c47203ce5 /tests/ref.rs | |
parent | d8bda60c3d8f906f1018012f4a55c7b894afb4b7 (diff) | |
download | alacritty-2234234ca9a2ab0d7eccd46893cbe6799b051aba.tar.gz alacritty-2234234ca9a2ab0d7eccd46893cbe6799b051aba.zip |
Enable history comparison in ref-tests
Previously ref-tests just ignored the scrollback history to keep
the old tests working, this would lead to new tests which rely on
scrollback history to succeeed even though they should not.
This has been fixed and it is now possible to create ref-tests with and
without scrollback history. When available the scrollback history is
compared, but the old tests still work without having to adjust them.
This fixes #1244.
Diffstat (limited to 'tests/ref.rs')
-rw-r--r-- | tests/ref.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/ref.rs b/tests/ref.rs index 6836a9f5..306b71a9 100644 --- a/tests/ref.rs +++ b/tests/ref.rs @@ -9,10 +9,11 @@ use alacritty::Grid; use alacritty::grid::IndexRegion; use alacritty::Term; use alacritty::ansi; -use alacritty::index::{Line, Column}; +use alacritty::index::Column; use alacritty::term::Cell; use alacritty::term::SizeInfo; use alacritty::util::fmt::{Red, Green}; +use alacritty::config::Config; macro_rules! ref_tests { ($($name:ident)*) => { @@ -47,6 +48,7 @@ ref_tests! { vttest_scroll vttest_tab_clear_set zsh_tab_completion + history } fn read_u8<P>(path: P) -> Vec<u8> @@ -77,7 +79,10 @@ fn ref_test(dir: &Path) { let size: SizeInfo = json::from_str(&serialized_size).unwrap(); let grid: Grid<Cell> = json::from_str(&serialized_grid).unwrap(); - let mut terminal = Term::new(&Default::default(), size); + let mut config: Config = Default::default(); + config.set_history(grid.history_size() as u32); + + let mut terminal = Term::new(&config, size); let mut parser = ansi::Processor::new(); for byte in recording { @@ -85,10 +90,11 @@ fn ref_test(dir: &Path) { } if grid != *terminal.grid() { - for (i, row) in terminal.grid().region(..).into_iter().enumerate() { - for (j, cell) in row.iter().enumerate() { - let original_cell = &grid[Line(i)][Column(j)]; - if *original_cell != *cell { + for i in 0..(grid.num_lines().0 + grid.history_size()) { + for j in 0..grid.num_cols().0 { + let cell = terminal.grid()[i][Column(j)]; + let original_cell = grid[i][Column(j)]; + if original_cell != cell { println!("[{i}][{j}] {original:?} => {now:?}", i=i, j=j, original=Green(original_cell), now=Red(cell)); } |