diff options
| author | Yutaka Kamei <kamei@yykamei.me> | 2021-04-30 23:35:12 +0900 |
|---|---|---|
| committer | Yutaka Kamei <kamei@yykamei.me> | 2021-05-02 06:18:40 +0900 |
| commit | 168deabea7825f1b2bf81ec79de9f4bfaab8413e (patch) | |
| tree | dd413499bb1a77d1af25705217bfab86ce2f18b4 /src/tests/integration/basic.rs | |
| parent | Don't commit to master like an idiot... :( (diff) | |
| download | sl0ppij-168deabea7825f1b2bf81ec79de9f4bfaab8413e.tar.gz sl0ppij-168deabea7825f1b2bf81ec79de9f4bfaab8413e.tar.xz sl0ppij-168deabea7825f1b2bf81ec79de9f4bfaab8413e.zip | |
Load config before start()
Previously, a config file was loaded within `start()`, and if the config
file is invalid, Zellij was supposed to show a user what's wrong with
it. However, since `start()` starts setting up its terminal with an
alternative screen buffer, neither standard output nor standard error
could display such an error.
This change intends to address this issue by making Zellij load a config
file before `start()`.
In addition, the patch also includes some refactorings:
* Redefine `from_cli_config` with `TryFrom`, which was introduced in
Rust 1.34
* Remove conditional declaration `cfg(not(test))` because `start()` now
receive a `Config` as the third argument
* Introduce [`tempfile`](https://crates.io/crates/tempfile) in order to
run tests with actual files
* Typo?: "Deserialisation" -> "Deserialization"
Diffstat (limited to 'src/tests/integration/basic.rs')
| -rw-r--r-- | src/tests/integration/basic.rs | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/src/tests/integration/basic.rs b/src/tests/integration/basic.rs index 9b1b2bdd..f785666a 100644 --- a/src/tests/integration/basic.rs +++ b/src/tests/integration/basic.rs @@ -1,6 +1,7 @@ use crate::panes::PositionAndSize; use ::insta::assert_snapshot; +use crate::common::input::config::Config; use crate::tests::fakes::FakeInputOutput; use crate::tests::utils::commands::{ PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE, SCROLL_MODE, SCROLL_PAGE_DOWN_IN_SCROLL_MODE, @@ -26,7 +27,11 @@ pub fn starts_with_one_terminal() { }; let mut fake_input_output = get_fake_os_input(&fake_win_size); fake_input_output.add_terminal_input(&[&QUIT]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -49,7 +54,11 @@ pub fn split_terminals_vertically() { }; let mut fake_input_output = get_fake_os_input(&fake_win_size); fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_RIGHT_IN_PANE_MODE, &QUIT]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -72,7 +81,11 @@ pub fn split_terminals_horizontally() { }; let mut fake_input_output = get_fake_os_input(&fake_win_size); fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_DOWN_IN_PANE_MODE, &QUIT]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -102,7 +115,11 @@ pub fn split_largest_terminal() { &SPAWN_TERMINAL_IN_PANE_MODE, &QUIT, ]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -125,7 +142,11 @@ pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() { }; let mut fake_input_output = get_fake_os_input(&fake_win_size); fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_RIGHT_IN_PANE_MODE, &QUIT]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -148,7 +169,11 @@ pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() { }; let mut fake_input_output = get_fake_os_input(&fake_win_size); fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_DOWN_IN_PANE_MODE, &QUIT]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -171,7 +196,11 @@ pub fn cannot_split_largest_terminal_when_there_is_no_room() { }; let mut fake_input_output = get_fake_os_input(&fake_win_size); fake_input_output.add_terminal_input(&[&PANE_MODE, &SPAWN_TERMINAL_IN_PANE_MODE, &QUIT]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -202,7 +231,11 @@ pub fn scrolling_up_inside_a_pane() { &SCROLL_UP_IN_SCROLL_MODE, &QUIT, ]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -235,7 +268,11 @@ pub fn scrolling_down_inside_a_pane() { &SCROLL_DOWN_IN_SCROLL_MODE, &QUIT, ]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -265,7 +302,11 @@ pub fn scrolling_page_up_inside_a_pane() { &SCROLL_PAGE_UP_IN_SCROLL_MODE, &QUIT, ]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -298,7 +339,11 @@ pub fn scrolling_page_down_inside_a_pane() { &SCROLL_PAGE_DOWN_IN_SCROLL_MODE, &QUIT, ]); - start(Box::new(fake_input_output.clone()), CliArgs::default()); + start( + Box::new(fake_input_output.clone()), + CliArgs::default(), + Config::default(), + ); let output_frames = fake_input_output .stdout_writer .output_frames @@ -332,7 +377,7 @@ pub fn max_panes() { ]); let mut opts = CliArgs::default(); opts.max_panes = Some(4); - start(Box::new(fake_input_output.clone()), opts); + start(Box::new(fake_input_output.clone()), opts, Config::default()); let output_frames = fake_input_output .stdout_writer .output_frames @@ -364,7 +409,7 @@ pub fn toggle_focused_pane_fullscreen() { ]); let mut opts = CliArgs::default(); opts.max_panes = Some(4); - start(Box::new(fake_input_output.clone()), opts); + start(Box::new(fake_input_output.clone()), opts, Config::default()); let output_frames = fake_input_output .stdout_writer .output_frames |
