aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/e2e
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-09-30 10:25:48 +0200
committerGitHub <noreply@github.com>2021-09-30 10:25:48 +0200
commitd7e4ec65db028f1ea231d4bee689be394f95cbf5 (patch)
treeaa99bde6c270512dd2c462908095753f6a85876c /src/tests/e2e
parentfix(makefile): update `update-default-config` (#751) (diff)
downloadsl0ppij-d7e4ec65db028f1ea231d4bee689be394f95cbf5.tar.gz
sl0ppij-d7e4ec65db028f1ea231d4bee689be394f95cbf5.tar.xz
sl0ppij-d7e4ec65db028f1ea231d4bee689be394f95cbf5.zip
hotfix(stdin): poll for mouse hold in the stdin thread (#752)
* hotfix(stdin): poll for mouse hold in the stdin thread * add missing dont panic * style(fmt): make rustfmt happy
Diffstat (limited to 'src/tests/e2e')
-rw-r--r--src/tests/e2e/cases.rs2
-rw-r--r--src/tests/e2e/remote_runner.rs45
2 files changed, 46 insertions, 1 deletions
diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs
index 77892463..cdabef81 100644
--- a/src/tests/e2e/cases.rs
+++ b/src/tests/e2e/cases.rs
@@ -926,6 +926,7 @@ pub fn mirrored_sessions() {
// if no test timed out, we break the loop and assert the snapshot
let mut first_runner =
RemoteRunner::new_with_session_name("mirrored_sessions", fake_win_size, session_name)
+ .dont_panic()
.add_step(Step {
name: "Split pane to the right",
instruction: |mut remote_terminal: RemoteTerminal| -> bool {
@@ -959,6 +960,7 @@ pub fn mirrored_sessions() {
let mut second_runner =
RemoteRunner::new_existing_session("mirrored_sessions", fake_win_size, session_name)
+ .dont_panic()
.add_step(Step {
name: "Make sure session appears correctly",
instruction: |remote_terminal: RemoteTerminal| -> bool {
diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs
index b2d517c4..db5c4685 100644
--- a/src/tests/e2e/remote_runner.rs
+++ b/src/tests/e2e/remote_runner.rs
@@ -211,6 +211,7 @@ pub struct RemoteRunner {
without_frames: bool,
session_name: Option<String>,
attach_to_existing: bool,
+ panic_on_no_retries_left: bool,
pub test_timed_out: bool,
}
@@ -247,6 +248,7 @@ impl RemoteRunner {
session_name: None,
attach_to_existing: false,
test_timed_out: false,
+ panic_on_no_retries_left: true,
}
}
pub fn new_with_session_name(
@@ -285,6 +287,7 @@ impl RemoteRunner {
session_name: Some(String::from(session_name)),
attach_to_existing: false,
test_timed_out: false,
+ panic_on_no_retries_left: true,
}
}
pub fn new_existing_session(
@@ -323,6 +326,7 @@ impl RemoteRunner {
session_name: Some(String::from(session_name)),
attach_to_existing: true,
test_timed_out: false,
+ panic_on_no_retries_left: true,
}
}
pub fn new_without_frames(test_name: &'static str, win_size: Size) -> Self {
@@ -357,6 +361,7 @@ impl RemoteRunner {
session_name: None,
attach_to_existing: false,
test_timed_out: false,
+ panic_on_no_retries_left: true,
}
}
pub fn new_with_layout(
@@ -396,8 +401,13 @@ impl RemoteRunner {
session_name: None,
attach_to_existing: false,
test_timed_out: false,
+ panic_on_no_retries_left: true,
}
}
+ pub fn dont_panic(mut self) -> Self {
+ self.panic_on_no_retries_left = false;
+ self
+ }
pub fn add_step(mut self, step: Step) -> Self {
self.steps.push(step);
self
@@ -405,6 +415,35 @@ impl RemoteRunner {
pub fn replace_steps(&mut self, steps: Vec<Step>) {
self.steps = steps;
}
+ fn display_informative_error(&mut self) {
+ let test_name = self.test_name;
+ let current_step_name = self.currently_running_step.as_ref().cloned();
+ match current_step_name {
+ Some(current_step) => {
+ let remote_terminal = self.current_remote_terminal_state();
+ eprintln!("Timed out waiting for data on the SSH channel for test {}. Was waiting for step: {}", test_name, current_step);
+ eprintln!("{:?}", remote_terminal);
+ }
+ None => {
+ let remote_terminal = self.current_remote_terminal_state();
+ eprintln!("Timed out waiting for data on the SSH channel for test {}. Haven't begun running steps yet.", test_name);
+ eprintln!("{:?}", remote_terminal);
+ }
+ }
+ }
+ pub fn get_current_snapshot(&mut self) -> String {
+ take_snapshot(&mut self.terminal_output)
+ }
+ fn current_remote_terminal_state(&mut self) -> RemoteTerminal {
+ let current_snapshot = self.get_current_snapshot();
+ let (cursor_x, cursor_y) = self.terminal_output.cursor_coordinates().unwrap_or((0, 0));
+ RemoteTerminal {
+ cursor_x,
+ cursor_y,
+ current_snapshot,
+ channel: &mut self.channel,
+ }
+ }
pub fn run_next_step(&mut self) {
if let Some(next_step) = self.steps.get(self.current_step_index) {
let current_snapshot = take_snapshot(&mut self.terminal_output);
@@ -482,11 +521,15 @@ impl RemoteRunner {
break;
}
}
- Err(_e) => {
+ Err(e) => {
if self.retries_left > 0 {
return self.restart_test();
}
self.test_timed_out = true;
+ if self.panic_on_no_retries_left {
+ self.display_informative_error();
+ panic!("timed out waiting for test: {:?}", e);
+ }
}
}
}