Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins): update and render plugins asynchronously #2410

Merged
merged 10 commits into from
Apr 28, 2023
Merged
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ suggest = "0.4"
insta = { version = "1.6.0", features = ["backtrace"] }
ssh2 = "0.9.1"
rand = "0.8.0"
regex = "1.8.1"

[workspace]
members = [
Expand Down
52 changes: 52 additions & 0 deletions src/tests/e2e/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ::insta::assert_snapshot;
use zellij_utils::{pane_size::Size, position::Position};

use rand::Rng;
use regex::Regex;

use std::fmt::Write;
use std::path::Path;
Expand Down Expand Up @@ -74,6 +75,26 @@ pub fn sgr_mouse_report(position: Position, button: u8) -> Vec<u8> {
.to_vec()
}

// what we do here is adjust snapshots for various race conditions that should hopefully be
// temporary until we can fix them - when adding stuff here, please add a detailed comment
// explaining the race condition and what needs to be done to solve it
fn account_for_races_in_snapshot(snapshot: String) -> String {
// these replacements need to be done because plugins set themselves as "unselectable" at runtime
// when they are loaded - since they are loaded asynchronously, sometimes the "BASE" indication
// (which should only happen if there's more than one selectable pane) is rendered and
// sometimes it isn't - this removes it entirely
//
// to fix this, we should set plugins as unselectable in the layout (before they are loaded),
// once that happens, we should be able to remove this hack (and adjust the snapshots for the
// trailing spaces that we had to get rid of here)
let base_replace = Regex::new(r" BASE \s*\n").unwrap();
let eol_arrow_replace = Regex::new(r"\s*\n").unwrap();
let snapshot = base_replace.replace_all(&snapshot, "\n").to_string();
let snapshot = eol_arrow_replace.replace_all(&snapshot, "\n").to_string();

snapshot
}

// All the E2E tests are marked as "ignored" so that they can be run separately from the normal
// tests

Expand Down Expand Up @@ -105,6 +126,8 @@ pub fn starts_with_one_terminal() {
break last_snapshot;
}
};

let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -152,6 +175,7 @@ pub fn split_terminals_vertically() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -195,6 +219,7 @@ pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -272,6 +297,7 @@ pub fn scrolling_inside_a_pane() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -332,6 +358,7 @@ pub fn toggle_pane_fullscreen() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -396,6 +423,7 @@ pub fn open_new_tab() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -536,6 +564,7 @@ pub fn close_pane() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -680,6 +709,7 @@ pub fn typing_exit_closes_pane() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -742,6 +772,7 @@ pub fn resize_pane() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -801,6 +832,7 @@ pub fn lock_mode() {
break last_snapshot;
}
};
// let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -864,6 +896,7 @@ pub fn resize_terminal_window() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -949,6 +982,7 @@ pub fn detach_and_attach_session() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -984,6 +1018,7 @@ pub fn status_bar_loads_custom_keybindings() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1043,6 +1078,7 @@ fn focus_pane_with_mouse() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1118,6 +1154,7 @@ pub fn scrolling_inside_a_pane_with_mouse() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1164,6 +1201,7 @@ pub fn start_without_pane_frames() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1308,6 +1346,8 @@ pub fn mirrored_sessions() {
break (first_runner_snapshot, second_runner_snapshot);
}
};
let first_runner_snapshot = account_for_races_in_snapshot(first_runner_snapshot);
let second_runner_snapshot = account_for_races_in_snapshot(second_runner_snapshot);
assert_snapshot!(first_runner_snapshot);
assert_snapshot!(second_runner_snapshot);
}
Expand Down Expand Up @@ -1396,6 +1436,8 @@ pub fn multiple_users_in_same_pane_and_tab() {
break (first_runner_snapshot, second_runner_snapshot);
}
};
let first_runner_snapshot = account_for_races_in_snapshot(first_runner_snapshot);
let second_runner_snapshot = account_for_races_in_snapshot(second_runner_snapshot);
assert_snapshot!(first_runner_snapshot);
assert_snapshot!(second_runner_snapshot);
}
Expand Down Expand Up @@ -1486,6 +1528,8 @@ pub fn multiple_users_in_different_panes_and_same_tab() {
break (first_runner_snapshot, second_runner_snapshot);
}
};
let first_runner_snapshot = account_for_races_in_snapshot(first_runner_snapshot);
let second_runner_snapshot = account_for_races_in_snapshot(second_runner_snapshot);
assert_snapshot!(first_runner_snapshot);
assert_snapshot!(second_runner_snapshot);
}
Expand Down Expand Up @@ -1581,6 +1625,8 @@ pub fn multiple_users_in_different_tabs() {
break (first_runner_snapshot, second_runner_snapshot);
}
};
let first_runner_snapshot = account_for_races_in_snapshot(first_runner_snapshot);
let second_runner_snapshot = account_for_races_in_snapshot(second_runner_snapshot);
assert_snapshot!(first_runner_snapshot);
assert_snapshot!(second_runner_snapshot);
}
Expand Down Expand Up @@ -1637,6 +1683,7 @@ pub fn bracketed_paste() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1684,6 +1731,7 @@ pub fn toggle_floating_panes() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1731,6 +1779,7 @@ pub fn tmux_mode() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1829,6 +1878,7 @@ pub fn undo_rename_tab() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1878,6 +1928,7 @@ pub fn undo_rename_pane() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}

Expand Down Expand Up @@ -1987,5 +2038,6 @@ pub fn send_command_through_the_cli() {
break last_snapshot;
}
};
let last_snapshot = account_for_races_in_snapshot(last_snapshot);
assert_snapshot!(last_snapshot);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1640
assertion_line: 1676
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│$ ^Tnabc█ │
│ │
Expand All @@ -25,5 +25,5 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Tip: Alt + <n> => new pane. Alt + <←↓↑→> or Alt + <hjkl> => navigate. Alt + <+|-> => resize pane.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 538
assertion_line: 557
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│$ █ │
│ │
Expand All @@ -25,5 +25,5 @@ expression: last_snapshot
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Tip: Alt + <n> => new pane. Alt + <←↓↑→> or Alt + <hjkl> => navigate. Alt + <+|-> => resize pane.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 952
assertion_line: 975
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────────────────────┐
│$ ││$ I am some text█ │
│ ││ │
Expand All @@ -25,5 +25,5 @@ expression: last_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  BASE 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Tip: Alt + <n> => new pane. Alt + <←↓↑→> or Alt + <hjkl> => navigate. Alt + <+|-> => resize pane.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 1046
assertion_line: 1071
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
Zellij (e2e-test)  Tab #1 
┌ Pane #1 ─────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────────────────────┐
│$ █ ││$ │
│ ││ │
Expand All @@ -25,5 +25,5 @@ expression: last_snapshot
│ ││ │
│ ││ │
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT  BASE 
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SEARCH  <o> SESSION  <q> QUIT 
Tip: Alt + <n> => new pane. Alt + <←↓↑→> or Alt + <hjkl> => navigate. Alt + <+|-> => resize pane.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/tests/e2e/cases.rs
assertion_line: 804
assertion_line: 819
expression: last_snapshot
---
Zellij (e2e-test)  Tab #1 
Expand Down
Loading