aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/e2e/remote_runner.rs
diff options
context:
space:
mode:
authorBrooks Rady <b.j.rady@gmail.com>2021-08-28 17:46:24 +0100
committerGitHub <noreply@github.com>2021-08-28 17:46:24 +0100
commit76a5bc8a05c33fb3f46cff1ce95aa1af694b9927 (patch)
treeaa0c9e4b317d9d01906d11817b3b57f0047d7be8 /src/tests/e2e/remote_runner.rs
parentfix(plugin): fix set_timeout() host function (diff)
downloadsl0ppij-76a5bc8a05c33fb3f46cff1ce95aa1af694b9927.tar.gz
sl0ppij-76a5bc8a05c33fb3f46cff1ce95aa1af694b9927.tar.xz
sl0ppij-76a5bc8a05c33fb3f46cff1ce95aa1af694b9927.zip
feat(ui): overhauled resize and layout systems
* refactor(panes): move to parametric pane sizes * Fixed the simpler errors by casting to usize * The least I can do is pass the formatting check... * Move to stable toolchain * Well, it compiles? * And now it doesn't! ;) * Baseline functionality with the new Dimension type * Working POC for percent-based resizing * REVERT THIS COMMIT – DELETES TESTS * Perfected the discrete resize algorithm * Fixed fixed-size panes * Basic bidirectional resize * feat(resize): finalised parametric resize algorithm * Reduce the logging level a bit * Fixed nested layouts using percents * Bug squishing for implicit sizing * Here is a funky (read: rubbish) rounding approach * And now it's gone again! * Improve discretisation algorithm to fix rounding errors * Fix the last layout bug (maybe?) * Mixed explicit and implied percents work now * Let's pretend that didn't happen... * Make things a bit less crashy * Crash slightly more for now (to find bugs) * Manaually splitting of panes works now * Start moving to percent-based resizes * Everything but fullscreen seems to be working * Fix compilatation errors * Culled a massive amount of border code * Why not pause to please rustfmt? * Turns out I was still missing a few tests... * Bringing back even more tests! * Fix tests and pane boarders * Fix the resize system without gaps * Fix content offset * Fixed a bug with pane closing * Add a hack to fix setting of the viewport * Fix toggling between shared borders and frames * fix(tests): make e2e properly use PaneGeom * style(fmt): make rustfmt happy * Revert unintentional rounding of borders * Purge some old borderless stuff * Fix busted tab-bar shrinking * Update E2E tests * Finish implementing fullscreen! * Don't crash anymore? * Fix (almost) all tests * Fix a lack of tab-stops * All tests passing * I really can't be bothered to debug a CI issue * Tie up loose ends * Knock out some lingering FIXMEs * Continue to clean things up * Change some naming and address FIXMEs * Cull more code + FIXMEs * Refactor of the resize system + polish * Only draw frames when absolutely necessary * Fix the tab-bar crash * Fix rendering of boarders on reattach * Fix resizing at small pane sizes * Deduplicate code in the layout system * Update tab-bar WASM * Fixed the pinching of panes during resize * Unexpose needlessly public type * Add back a lost test * Re-add tab tests and get them to compile * All tabs need layouts * Start fixing tests + bug in main * Stabilize the resize algorithm rounding * All tests from main are now passing * Cull more dead code
Diffstat (limited to 'src/tests/e2e/remote_runner.rs')
-rw-r--r--src/tests/e2e/remote_runner.rs179
1 files changed, 83 insertions, 96 deletions
diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs
index 819bee86..de9c35ed 100644
--- a/src/tests/e2e/remote_runner.rs
+++ b/src/tests/e2e/remote_runner.rs
@@ -1,7 +1,7 @@
use zellij_tile::data::Palette;
-use zellij_utils::pane_size::PositionAndSize;
use zellij_server::panes::TerminalPane;
+use zellij_utils::pane_size::{Dimension, PaneGeom, Size};
use zellij_utils::{vte, zellij_tile};
use ssh2::Session;
@@ -15,6 +15,7 @@ const ZELLIJ_LAYOUT_PATH: &str = "/usr/src/zellij/fixtures/layouts";
const CONNECTION_STRING: &str = "127.0.0.1:2222";
const CONNECTION_USERNAME: &str = "test";
const CONNECTION_PASSWORD: &str = "test";
+const SESSION_NAME: &str = "e2e-test";
fn ssh_connect() -> ssh2::Session {
let tcp = TcpStream::connect(CONNECTION_STRING).unwrap();
@@ -27,7 +28,7 @@ fn ssh_connect() -> ssh2::Session {
sess
}
-fn setup_remote_environment(channel: &mut ssh2::Channel, win_size: PositionAndSize) {
+fn setup_remote_environment(channel: &mut ssh2::Channel, win_size: Size) {
let (columns, rows) = (win_size.cols as u32, win_size.rows as u32);
channel
.request_pty("xterm", None, Some((columns, rows, 0, 0)))
@@ -39,60 +40,51 @@ fn setup_remote_environment(channel: &mut ssh2::Channel, win_size: PositionAndSi
channel.flush().unwrap();
}
-fn start_zellij(channel: &mut ssh2::Channel, session_name: Option<&String>) {
- match session_name.as_ref() {
- Some(name) => {
- channel
- .write_all(
- format!("{} --session {}\n", ZELLIJ_EXECUTABLE_LOCATION, name).as_bytes(),
- )
- .unwrap();
- }
- None => {
- channel
- .write_all(format!("{}\n", ZELLIJ_EXECUTABLE_LOCATION).as_bytes())
- .unwrap();
- }
- };
+fn stop_zellij(channel: &mut ssh2::Channel) {
+ channel
+ .write_all("killall -KILL zellij\n".as_bytes())
+ .unwrap();
+}
+
+fn start_zellij(channel: &mut ssh2::Channel) {
+ stop_zellij(channel);
+ channel
+ .write_all(
+ format!(
+ "{} --session {}\n",
+ ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME
+ )
+ .as_bytes(),
+ )
+ .unwrap();
channel.flush().unwrap();
}
fn start_zellij_without_frames(channel: &mut ssh2::Channel) {
+ stop_zellij(channel);
channel
- .write_all(format!("{} options --no-pane-frames\n", ZELLIJ_EXECUTABLE_LOCATION).as_bytes())
+ .write_all(
+ format!(
+ "{} --session {} options --no-pane-frames\n",
+ ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME
+ )
+ .as_bytes(),
+ )
.unwrap();
channel.flush().unwrap();
}
-fn start_zellij_with_layout(
- channel: &mut ssh2::Channel,
- layout_path: &str,
- session_name: Option<&String>,
-) {
- match session_name.as_ref() {
- Some(name) => {
- channel
- .write_all(
- format!(
- "{} --layout-path {} --session {}\n",
- ZELLIJ_EXECUTABLE_LOCATION, layout_path, name
- )
- .as_bytes(),
- )
- .unwrap();
- }
- None => {
- channel
- .write_all(
- format!(
- "{} --layout-path {}\n",
- ZELLIJ_EXECUTABLE_LOCATION, layout_path
- )
- .as_bytes(),
- )
- .unwrap();
- }
- };
+fn start_zellij_with_layout(channel: &mut ssh2::Channel, layout_path: &str) {
+ stop_zellij(channel);
+ channel
+ .write_all(
+ format!(
+ "{} --layout-path {} --session {}\n",
+ ZELLIJ_EXECUTABLE_LOCATION, layout_path, SESSION_NAME
+ )
+ .as_bytes(),
+ )
+ .unwrap();
channel.flush().unwrap();
}
@@ -119,7 +111,6 @@ pub fn take_snapshot(terminal_output: &mut TerminalPane) -> String {
pub struct RemoteTerminal<'a> {
channel: &'a mut ssh2::Channel,
- session_name: Option<&'a String>,
cursor_x: usize,
cursor_y: usize,
current_snapshot: String,
@@ -174,12 +165,7 @@ impl<'a> RemoteTerminal<'a> {
pub fn attach_to_original_session(&mut self) {
self.channel
.write_all(
- format!(
- "{} attach {}\n",
- ZELLIJ_EXECUTABLE_LOCATION,
- self.session_name.unwrap()
- )
- .as_bytes(),
+ format!("{} attach {}\n", ZELLIJ_EXECUTABLE_LOCATION, SESSION_NAME).as_bytes(),
)
.unwrap();
self.channel.flush().unwrap();
@@ -198,33 +184,37 @@ pub struct RemoteRunner {
vte_parser: vte::Parser,
terminal_output: TerminalPane,
channel: ssh2::Channel,
- session_name: Option<String>,
test_name: &'static str,
currently_running_step: Option<String>,
retries_left: usize,
- win_size: PositionAndSize,
+ win_size: Size,
layout_file_name: Option<&'static str>,
without_frames: bool,
}
impl RemoteRunner {
- pub fn new(
- test_name: &'static str,
- win_size: PositionAndSize,
- session_name: Option<String>,
- ) -> Self {
+ pub fn new(test_name: &'static str, win_size: Size) -> Self {
let sess = ssh_connect();
let mut channel = sess.channel_session().unwrap();
let vte_parser = vte::Parser::new();
- let terminal_output = TerminalPane::new(0, win_size, Palette::default(), 0); // 0 is the pane index
+ let mut rows = Dimension::fixed(win_size.rows);
+ let mut cols = Dimension::fixed(win_size.cols);
+ rows.set_inner(win_size.rows);
+ cols.set_inner(win_size.cols);
+ let pane_geom = PaneGeom {
+ x: 0,
+ y: 0,
+ rows,
+ cols,
+ };
+ let terminal_output = TerminalPane::new(0, pane_geom, Palette::default(), 0); // 0 is the pane index
setup_remote_environment(&mut channel, win_size);
- start_zellij(&mut channel, session_name.as_ref());
+ start_zellij(&mut channel);
RemoteRunner {
steps: vec![],
channel,
terminal_output,
vte_parser,
- session_name,
test_name,
currently_running_step: None,
current_step_index: 0,
@@ -234,15 +224,21 @@ impl RemoteRunner {
without_frames: false,
}
}
- pub fn new_without_frames(
- test_name: &'static str,
- win_size: PositionAndSize,
- session_name: Option<String>,
- ) -> Self {
+ pub fn new_without_frames(test_name: &'static str, win_size: Size) -> Self {
let sess = ssh_connect();
let mut channel = sess.channel_session().unwrap();
let vte_parser = vte::Parser::new();
- let terminal_output = TerminalPane::new(0, win_size, Palette::default(), 0); // 0 is the pane index
+ let mut rows = Dimension::fixed(win_size.rows);
+ let mut cols = Dimension::fixed(win_size.cols);
+ rows.set_inner(win_size.rows);
+ cols.set_inner(win_size.cols);
+ let pane_geom = PaneGeom {
+ x: 0,
+ y: 0,
+ rows,
+ cols,
+ };
+ let terminal_output = TerminalPane::new(0, pane_geom, Palette::default(), 0); // 0 is the pane index
setup_remote_environment(&mut channel, win_size);
start_zellij_without_frames(&mut channel);
RemoteRunner {
@@ -250,7 +246,6 @@ impl RemoteRunner {
channel,
terminal_output,
vte_parser,
- session_name,
test_name,
currently_running_step: None,
current_step_index: 0,
@@ -262,27 +257,31 @@ impl RemoteRunner {
}
pub fn new_with_layout(
test_name: &'static str,
- win_size: PositionAndSize,
+ win_size: Size,
layout_file_name: &'static str,
- session_name: Option<String>,
) -> Self {
let remote_path = Path::new(ZELLIJ_LAYOUT_PATH).join(layout_file_name);
let sess = ssh_connect();
let mut channel = sess.channel_session().unwrap();
let vte_parser = vte::Parser::new();
- let terminal_output = TerminalPane::new(0, win_size, Palette::default(), 0); // 0 is the pane index
+ let mut rows = Dimension::fixed(win_size.rows);
+ let mut cols = Dimension::fixed(win_size.cols);
+ rows.set_inner(win_size.rows);
+ cols.set_inner(win_size.cols);
+ let pane_geom = PaneGeom {
+ x: 0,
+ y: 0,
+ rows,
+ cols,
+ };
+ let terminal_output = TerminalPane::new(0, pane_geom, Palette::default(), 0); // 0 is the pane index
setup_remote_environment(&mut channel, win_size);
- start_zellij_with_layout(
- &mut channel,
- &remote_path.to_string_lossy(),
- session_name.as_ref(),
- );
+ start_zellij_with_layout(&mut channel, &remote_path.to_string_lossy());
RemoteRunner {
steps: vec![],
channel,
terminal_output,
vte_parser,
- session_name,
test_name,
currently_running_step: None,
current_step_index: 0,
@@ -307,7 +306,6 @@ impl RemoteRunner {
cursor_y,
current_snapshot,
channel: &mut self.channel,
- session_name: self.session_name.as_ref(),
}
}
pub fn run_next_step(&mut self) {
@@ -319,7 +317,6 @@ impl RemoteRunner {
cursor_y,
current_snapshot,
channel: &mut self.channel,
- session_name: self.session_name.as_ref(),
};
let instruction = next_step.instruction;
self.currently_running_step = Some(String::from(next_step.name));
@@ -332,32 +329,22 @@ impl RemoteRunner {
self.steps.get(self.current_step_index).is_some()
}
fn restart_test(&mut self) -> String {
- let session_name = self.session_name.as_ref().map(|name| {
- // this is so that we don't try to connect to the previous session if it's still stuck
- // inside the container
- format!("{}_{}", name, self.retries_left)
- });
if let Some(layout_file_name) = self.layout_file_name.as_ref() {
// let mut new_runner = RemoteRunner::new_with_layout(self.test_name, self.win_size, Path::new(&local_layout_path), session_name);
- let mut new_runner = RemoteRunner::new_with_layout(
- self.test_name,
- self.win_size,
- layout_file_name,
- session_name,
- );
+ let mut new_runner =
+ RemoteRunner::new_with_layout(self.test_name, self.win_size, layout_file_name);
new_runner.retries_left = self.retries_left - 1;
new_runner.replace_steps(self.steps.clone());
drop(std::mem::replace(self, new_runner));
self.run_all_steps()
} else if self.without_frames {
- let mut new_runner =
- RemoteRunner::new_without_frames(self.test_name, self.win_size, session_name);
+ let mut new_runner = RemoteRunner::new_without_frames(self.test_name, self.win_size);
new_runner.retries_left = self.retries_left - 1;
new_runner.replace_steps(self.steps.clone());
drop(std::mem::replace(self, new_runner));
self.run_all_steps()
} else {
- let mut new_runner = RemoteRunner::new(self.test_name, self.win_size, session_name);
+ let mut new_runner = RemoteRunner::new(self.test_name, self.win_size);
new_runner.retries_left = self.retries_left - 1;
new_runner.replace_steps(self.steps.clone());
drop(std::mem::replace(self, new_runner));