From ed4fd2a8e77df304539ca7f445a78039028eaa8a Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Wed, 30 Jun 2021 11:27:35 +0200 Subject: chore(tests): move all integration tests to be either unit or e2e tests - remove old testing infra (#589) * tests(integration): move basic integration tests to be unit tests * fix(tests): silently fail threadbus for tests * tests(unit): move compatibility tests to become unit tests for grid * tests(unit): move close_pane tests to become unit tests for grid * tests(e2e): move basic layout test to e2e * tests(unit): move move_focus tests to be unit tests * tests(unit): move resize_down tests to be unit tests * tests(unit): move resize_left tests to be unit tests * tests(unit): move resize_right tests to be unit tests * tests(unit): move resize_up tests to be unit tests * tests(infra): remove unused infra * style(fmt): make rustfmt happy * debug * debug * debug * debug * chore(test): shift volume mounting around because github actions is a special child --- src/tests/e2e/cases.rs | 83 ++- src/tests/e2e/remote_runner.rs | 107 ++- ...j__tests__e2e__cases__accepts_basic_layout.snap | 29 + src/tests/fakes.rs | 329 ---------- src/tests/integration/basic.rs | 498 -------------- src/tests/integration/close_pane.rs | 674 ------------------- src/tests/integration/compatibility.rs | 681 ------------------- src/tests/integration/layouts.rs | 67 -- src/tests/integration/mod.rs | 15 - src/tests/integration/move_focus_down.rs | 91 --- src/tests/integration/move_focus_left.rs | 131 ---- src/tests/integration/move_focus_right.rs | 131 ---- src/tests/integration/move_focus_up.rs | 91 --- src/tests/integration/resize_down.rs | 725 --------------------- src/tests/integration/resize_left.rs | 702 -------------------- src/tests/integration/resize_right.rs | 701 -------------------- src/tests/integration/resize_up.rs | 719 -------------------- ...tests__integration__basic__bracketed_paste.snap | 25 - ...lit_largest_terminal_when_there_is_no_room.snap | 9 - ...zontally_when_active_terminal_is_too_small.snap | 9 - ...rtically_when_active_terminal_is_too_small.snap | 25 - ...llij__tests__integration__basic__max_panes.snap | 25 - ...ation__basic__scrolling_down_inside_a_pane.snap | 25 - ...__basic__scrolling_page_down_inside_a_pane.snap | 25 - ...on__basic__scrolling_page_up_inside_a_pane.snap | 25 - ...gration__basic__scrolling_up_inside_a_pane.snap | 25 - ...integration__basic__split_largest_terminal.snap | 25 - ...ation__basic__split_terminals_horizontally.snap | 25 - ...gration__basic__split_terminals_vertically.snap | 25 - ...tegration__basic__starts_with_one_terminal.snap | 25 - ...ion__basic__toggle_focused_pane_fullscreen.snap | 25 - ...ane__close_pane_with_another_pane_above_it.snap | 25 - ...ane__close_pane_with_another_pane_below_it.snap | 25 - ...__close_pane_with_another_pane_to_the_left.snap | 25 - ..._close_pane_with_another_pane_to_the_right.snap | 25 - ...e__close_pane_with_multiple_panes_above_it.snap | 25 - ...iple_panes_above_it_away_from_screen_edges.snap | 25 - ...e__close_pane_with_multiple_panes_below_it.snap | 25 - ...iple_panes_below_it_away_from_screen_edges.snap | 25 - ...close_pane_with_multiple_panes_to_the_left.snap | 25 - ...e_panes_to_the_left_away_from_screen_edges.snap | 35 - ...lose_pane_with_multiple_panes_to_the_right.snap | 25 - ..._panes_to_the_right_away_from_screen_edges.snap | 35 - ...n__close_pane__closing_last_pane_exits_app.snap | 25 - ...ation__compatibility__bash_cursor_linewrap.snap | 33 - ...ration__compatibility__clear_scroll_region.snap | 33 - ...atibility__display_tab_characters_properly.snap | 33 - ..._integration__compatibility__emacs_longbuf.snap | 65 -- ...gration__compatibility__exa_plus_omf_theme.snap | 61 -- ...ation__compatibility__fish_paste_multiline.snap | 33 - ...bility__fish_select_tab_completion_options.snap | 33 - ...compatibility__fish_tab_completion_options.snap | 33 - ...egration__compatibility__git_diff_scrollup.snap | 33 - ...tests__integration__compatibility__git_log.snap | 33 - ...j__tests__integration__compatibility__htop.snap | 33 - ...ation__compatibility__htop_right_scrolling.snap | 33 - ...integration__compatibility__htop_scrolling.snap | 33 - ...gration__compatibility__neovim_insert_mode.snap | 33 - ...mpatibility__run_bandwhich_from_fish_shell.snap | 33 - ...__integration__compatibility__top_and_quit.snap | 61 -- ...ts__integration__compatibility__vim_ctrl_d.snap | 33 - ...ts__integration__compatibility__vim_ctrl_u.snap | 33 - ..._integration__compatibility__vim_overwrite.snap | 33 - ...ion__compatibility__vim_scroll_region_down.snap | 33 - ...tegration__layouts__accepts_basic_layout-2.snap | 25 - ...tegration__layouts__accepts_basic_layout-3.snap | 25 - ...integration__layouts__accepts_basic_layout.snap | 25 - ...egration__move_focus_down__move_focus_down.snap | 25 - ...wn__move_focus_down_to_the_largest_overlap.snap | 25 - ..._focus_down_to_the_most_recently_used_pane.snap | 25 - ...egration__move_focus_left__move_focus_left.snap | 25 - ...ve_focus_left__move_focus_left_changes_tab.snap | 25 - ...ft__move_focus_left_to_the_largest_overlap.snap | 25 - ..._focus_left_to_the_most_recently_used_pane.snap | 25 - ...ration__move_focus_right__move_focus_right.snap | 25 - ..._focus_right__move_focus_right_changes_tab.snap | 25 - ...t__move_focus_right_to_the_largest_overlap.snap | 25 - ...focus_right_to_the_most_recently_used_pane.snap | 25 - ..._integration__move_focus_up__move_focus_up.snap | 25 - ...s_up__move_focus_up_to_the_largest_overlap.snap | 25 - ...ve_focus_up_to_the_most_recently_used_pane.snap | 25 - ..._down_when_pane_below_is_at_minimum_height.snap | 12 - ...own__resize_down_with_multiple_panes_above.snap | 25 - ...__resize_down__resize_down_with_pane_above.snap | 25 - ...__resize_down__resize_down_with_pane_below.snap | 25 - ...e_aligned_left_and_right_with_current_pane.snap | 25 - ...and_right_with_panes_to_the_left_and_right.snap | 45 -- ...panes_above_aligned_left_with_current_pane.snap | 25 - ...anes_above_aligned_right_with_current_pane.snap | 25 - ...wn__resize_down_with_panes_above_and_below.snap | 30 - ...w_aligned_left_and_right_with_current_pane.snap | 25 - ..._left_and_right_with_to_the_left_and_right.snap | 45 -- ...panes_below_aligned_left_with_current_pane.snap | 25 - ...anes_below_aligned_right_with_current_pane.snap | 25 - ..._when_pane_to_the_left_is_at_minimum_width.snap | 25 - ...esize_left_with_multiple_panes_to_the_left.snap | 25 - ...ze_left__resize_left_with_pane_to_the_left.snap | 25 - ...e_left__resize_left_with_pane_to_the_right.snap | 25 - ..._the_left_aligned_bottom_with_current_pane.snap | 25 - ...t_aligned_top_and_bottom_with_current_pane.snap | 25 - ..._top_and_bottom_with_panes_above_and_below.snap | 45 -- ..._to_the_left_aligned_top_with_current_pane.snap | 25 - ...size_left_with_panes_to_the_left_and_right.snap | 25 - ...the_right_aligned_bottom_with_current_pane.snap | 25 - ...t_aligned_top_and_bottom_with_current_pane.snap | 25 - ..._top_and_bottom_with_panes_above_and_below.snap | 45 -- ...to_the_right_aligned_top_with_current_pane.snap | 25 - ..._when_pane_to_the_left_is_at_minimum_width.snap | 25 - ...size_right_with_multiple_panes_to_the_left.snap | 25 - ..._right__resize_right_with_pane_to_the_left.snap | 25 - ...right__resize_right_with_pane_to_the_right.snap | 25 - ..._the_left_aligned_bottom_with_current_pane.snap | 25 - ...t_aligned_top_and_bottom_with_current_pane.snap | 25 - ..._top_and_bottom_with_panes_above_and_below.snap | 45 -- ..._to_the_left_aligned_top_with_current_pane.snap | 25 - ...ize_right_with_panes_to_the_left_and_right.snap | 25 - ...the_right_aligned_bottom_with_current_pane.snap | 25 - ...t_aligned_top_and_bottom_with_current_pane.snap | 25 - ..._top_and_bottom_with_panes_above_and_below.snap | 45 -- ...to_the_right_aligned_top_with_current_pane.snap | 25 - ...ze_up_when_pane_above_is_at_minimum_height.snap | 12 - ...ze_up__resize_up_with_multiple_panes_above.snap | 25 - ...tion__resize_up__resize_up_with_pane_above.snap | 25 - ...tion__resize_up__resize_up_with_pane_below.snap | 25 - ...e_aligned_left_and_right_with_current_pane.snap | 25 - ...and_right_with_panes_to_the_left_and_right.snap | 45 -- ...panes_above_aligned_left_with_current_pane.snap | 25 - ...anes_above_aligned_right_with_current_pane.snap | 25 - ...e_up__resize_up_with_panes_above_and_below.snap | 25 - ...w_aligned_left_and_right_with_current_pane.snap | 25 - ..._left_and_right_with_to_the_left_and_right.snap | 45 -- ...panes_below_aligned_left_with_current_pane.snap | 25 - ...anes_below_aligned_right_with_current_pane.snap | 25 - ...ntegration__tabs__close_last_pane_in_a_tab.snap | 25 - ...ellij__tests__integration__tabs__close_tab.snap | 25 - ...s__integration__tabs__close_the_middle_tab.snap | 25 - ...lose_the_tab_that_has_a_pane_in_fullscreen.snap | 25 - ...tion__tabs__closing_last_tab_exits_the_app.snap | 25 - ...ij__tests__integration__tabs__open_new_tab.snap | 25 - ...sts__integration__tabs__switch_to_next_tab.snap | 25 - ...sts__integration__tabs__switch_to_prev_tab.snap | 25 - ...size__window_height_increase_with_one_pane.snap | 25 - ...ow_width_and_height_decrease_with_one_pane.snap | 25 - ...esize__window_width_decrease_with_one_pane.snap | 25 - ...esize__window_width_increase_with_one_pane.snap | 25 - ...lscreen__adding_new_terminal_in_fullscreen.snap | 25 - ...reen__move_focus_is_disabled_in_fullscreen.snap | 25 - src/tests/integration/tabs.rs | 326 --------- src/tests/integration/terminal_window_resize.rs | 161 ----- src/tests/integration/toggle_fullscreen.rs | 89 --- src/tests/mod.rs | 36 - src/tests/possible_tty_inputs.rs | 103 --- src/tests/tty_inputs.rs | 550 ---------------- src/tests/utils.rs | 95 --- 154 files changed, 208 insertions(+), 10551 deletions(-) create mode 100644 src/tests/e2e/snapshots/zellij__tests__e2e__cases__accepts_basic_layout.snap delete mode 100644 src/tests/fakes.rs delete mode 100644 src/tests/integration/basic.rs delete mode 100644 src/tests/integration/close_pane.rs delete mode 100644 src/tests/integration/compatibility.rs delete mode 100644 src/tests/integration/layouts.rs delete mode 100644 src/tests/integration/mod.rs delete mode 100644 src/tests/integration/move_focus_down.rs delete mode 100644 src/tests/integration/move_focus_left.rs delete mode 100644 src/tests/integration/move_focus_right.rs delete mode 100644 src/tests/integration/move_focus_up.rs delete mode 100644 src/tests/integration/resize_down.rs delete mode 100644 src/tests/integration/resize_left.rs delete mode 100644 src/tests/integration/resize_right.rs delete mode 100644 src/tests/integration/resize_up.rs delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__bracketed_paste.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__cannot_split_largest_terminal_when_there_is_no_room.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__cannot_split_terminals_horizontally_when_active_terminal_is_too_small.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__cannot_split_terminals_vertically_when_active_terminal_is_too_small.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__max_panes.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__scrolling_down_inside_a_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__scrolling_page_down_inside_a_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__scrolling_page_up_inside_a_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__scrolling_up_inside_a_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__split_largest_terminal.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__split_terminals_horizontally.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__split_terminals_vertically.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__starts_with_one_terminal.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__basic__toggle_focused_pane_fullscreen.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_another_pane_above_it.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_another_pane_below_it.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_another_pane_to_the_left.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_another_pane_to_the_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_above_it.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_above_it_away_from_screen_edges.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_below_it.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_below_it_away_from_screen_edges.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_to_the_left.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_to_the_left_away_from_screen_edges.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_to_the_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__close_pane_with_multiple_panes_to_the_right_away_from_screen_edges.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__close_pane__closing_last_pane_exits_app.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__bash_cursor_linewrap.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__clear_scroll_region.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__display_tab_characters_properly.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__emacs_longbuf.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__exa_plus_omf_theme.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__fish_paste_multiline.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__fish_select_tab_completion_options.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__fish_tab_completion_options.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__git_diff_scrollup.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__git_log.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__htop.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__htop_right_scrolling.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__htop_scrolling.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__neovim_insert_mode.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__run_bandwhich_from_fish_shell.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__top_and_quit.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__vim_ctrl_d.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__vim_ctrl_u.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__vim_overwrite.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__compatibility__vim_scroll_region_down.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout-2.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout-3.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_down__move_focus_down.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_down__move_focus_down_to_the_largest_overlap.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_down__move_focus_down_to_the_most_recently_used_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_left__move_focus_left.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_left__move_focus_left_changes_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_left__move_focus_left_to_the_largest_overlap.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_left__move_focus_left_to_the_most_recently_used_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_right__move_focus_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_right__move_focus_right_changes_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_right__move_focus_right_to_the_largest_overlap.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_right__move_focus_right_to_the_most_recently_used_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_up__move_focus_up.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_up__move_focus_up_to_the_largest_overlap.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__move_focus_up__move_focus_up_to_the_most_recently_used_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__cannot_resize_down_when_pane_below_is_at_minimum_height.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_multiple_panes_above.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_pane_above.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_pane_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_above_aligned_left_and_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_above_aligned_left_and_right_with_panes_to_the_left_and_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_above_aligned_left_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_above_aligned_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_above_and_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_below_aligned_left_and_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_below_aligned_left_and_right_with_to_the_left_and_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_below_aligned_left_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_down__resize_down_with_panes_below_aligned_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__cannot_resize_left_when_pane_to_the_left_is_at_minimum_width.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_multiple_panes_to_the_left.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_pane_to_the_left.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_pane_to_the_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_left_aligned_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_panes_above_and_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_left_aligned_top_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_left_and_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_right_aligned_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_panes_above_and_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_left__resize_left_with_panes_to_the_right_aligned_top_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__cannot_resize_right_when_pane_to_the_left_is_at_minimum_width.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_multiple_panes_to_the_left.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_pane_to_the_left.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_pane_to_the_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_left_aligned_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_above_and_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_left_aligned_top_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_left_and_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_right_aligned_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_panes_above_and_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_right__resize_right_with_panes_to_the_right_aligned_top_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__cannot_resize_up_when_pane_above_is_at_minimum_height.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_multiple_panes_above.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_pane_above.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_pane_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_above_aligned_left_and_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_above_aligned_left_and_right_with_panes_to_the_left_and_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_above_aligned_left_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_above_aligned_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_above_and_below.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_below_aligned_left_and_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_below_aligned_left_and_right_with_to_the_left_and_right.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_below_aligned_left_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__resize_up__resize_up_with_panes_below_aligned_right_with_current_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__close_last_pane_in_a_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__close_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__close_the_middle_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__close_the_tab_that_has_a_pane_in_fullscreen.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__closing_last_tab_exits_the_app.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__open_new_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__switch_to_next_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__tabs__switch_to_prev_tab.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__terminal_window_resize__window_height_increase_with_one_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__terminal_window_resize__window_width_and_height_decrease_with_one_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__terminal_window_resize__window_width_decrease_with_one_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__terminal_window_resize__window_width_increase_with_one_pane.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__toggle_fullscreen__adding_new_terminal_in_fullscreen.snap delete mode 100644 src/tests/integration/snapshots/zellij__tests__integration__toggle_fullscreen__move_focus_is_disabled_in_fullscreen.snap delete mode 100644 src/tests/integration/tabs.rs delete mode 100644 src/tests/integration/terminal_window_resize.rs delete mode 100644 src/tests/integration/toggle_fullscreen.rs delete mode 100644 src/tests/possible_tty_inputs.rs delete mode 100644 src/tests/tty_inputs.rs delete mode 100644 src/tests/utils.rs (limited to 'src') diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs index 5af67074c..69233f25a 100644 --- a/src/tests/e2e/cases.rs +++ b/src/tests/e2e/cases.rs @@ -1,15 +1,58 @@ +#![allow(unused)] + use ::insta::assert_snapshot; use zellij_utils::pane_size::PositionAndSize; use rand::Rng; +use std::path::Path; + use super::remote_runner::{RemoteRunner, RemoteTerminal, Step}; -use crate::tests::utils::commands::{ - CLOSE_PANE_IN_PANE_MODE, DETACH_IN_SESSION_MODE, ENTER, LOCK_MODE, NEW_TAB_IN_TAB_MODE, - PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SCROLL_MODE, - SCROLL_UP_IN_SCROLL_MODE, SESSION_MODE, SPLIT_RIGHT_IN_PANE_MODE, TAB_MODE, - TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE, -}; + +pub const QUIT: [u8; 1] = [17]; // ctrl-q +pub const ESC: [u8; 1] = [27]; +pub const ENTER: [u8; 1] = [10]; // char '\n' +pub const LOCK_MODE: [u8; 1] = [7]; // ctrl-g + +pub const MOVE_FOCUS_LEFT_IN_NORMAL_MODE: [u8; 2] = [27, 104]; // alt-h +pub const MOVE_FOCUS_RIGHT_IN_NORMAL_MODE: [u8; 2] = [27, 108]; // alt-l + +pub const PANE_MODE: [u8; 1] = [16]; // ctrl-p +pub const SPAWN_TERMINAL_IN_PANE_MODE: [u8; 1] = [110]; // n +pub const MOVE_FOCUS_IN_PANE_MODE: [u8; 1] = [112]; // p +pub const SPLIT_DOWN_IN_PANE_MODE: [u8; 1] = [100]; // d +pub const SPLIT_RIGHT_IN_PANE_MODE: [u8; 1] = [114]; // r +pub const TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE: [u8; 1] = [102]; // f +pub const CLOSE_PANE_IN_PANE_MODE: [u8; 1] = [120]; // x +pub const MOVE_FOCUS_DOWN_IN_PANE_MODE: [u8; 1] = [106]; // j +pub const MOVE_FOCUS_UP_IN_PANE_MODE: [u8; 1] = [107]; // k +pub const MOVE_FOCUS_LEFT_IN_PANE_MODE: [u8; 1] = [104]; // h +pub const MOVE_FOCUS_RIGHT_IN_PANE_MODE: [u8; 1] = [108]; // l + +pub const SCROLL_MODE: [u8; 1] = [19]; // ctrl-s +pub const SCROLL_UP_IN_SCROLL_MODE: [u8; 1] = [107]; // k +pub const SCROLL_DOWN_IN_SCROLL_MODE: [u8; 1] = [106]; // j +pub const SCROLL_PAGE_UP_IN_SCROLL_MODE: [u8; 1] = [2]; // ctrl-b +pub const SCROLL_PAGE_DOWN_IN_SCROLL_MODE: [u8; 1] = [6]; // ctrl-f + +pub const RESIZE_MODE: [u8; 1] = [18]; // ctrl-r +pub const RESIZE_DOWN_IN_RESIZE_MODE: [u8; 1] = [106]; // j +pub const RESIZE_UP_IN_RESIZE_MODE: [u8; 1] = [107]; // k +pub const RESIZE_LEFT_IN_RESIZE_MODE: [u8; 1] = [104]; // h +pub const RESIZE_RIGHT_IN_RESIZE_MODE: [u8; 1] = [108]; // l + +pub const TAB_MODE: [u8; 1] = [20]; // ctrl-t +pub const NEW_TAB_IN_TAB_MODE: [u8; 1] = [110]; // n +pub const SWITCH_NEXT_TAB_IN_TAB_MODE: [u8; 1] = [108]; // l +pub const SWITCH_PREV_TAB_IN_TAB_MODE: [u8; 1] = [104]; // h +pub const CLOSE_TAB_IN_TAB_MODE: [u8; 1] = [120]; // x + +pub const SESSION_MODE: [u8; 1] = [15]; // ctrl-o +pub const DETACH_IN_SESSION_MODE: [u8; 1] = [100]; // d + +pub const BRACKETED_PASTE_START: [u8; 6] = [27, 91, 50, 48, 48, 126]; // \u{1b}[200~ +pub const BRACKETED_PASTE_END: [u8; 6] = [27, 91, 50, 48, 49, 126]; // \u{1b}[201 +pub const SLEEP: [u8; 0] = []; // All the E2E tests are marked as "ignored" so that they can be run separately from the normal // tests @@ -714,3 +757,31 @@ pub fn detach_and_attach_session() { .run_all_steps(); assert_snapshot!(last_snapshot); } + +#[test] +#[ignore] +pub fn accepts_basic_layout() { + let fake_win_size = PositionAndSize { + cols: 120, + rows: 24, + x: 0, + y: 0, + ..Default::default() + }; + let layout_file_name = "three-panes-with-nesting.yaml"; + let last_snapshot = RemoteRunner::new_with_layout("accepts_basic_layout", fake_win_size, layout_file_name, None) + .add_step(Step { + name: "Wait for app to load", + instruction: |remote_terminal: RemoteTerminal| -> bool { + let mut step_is_complete = false; + if remote_terminal.cursor_position_is(2, 0) + && remote_terminal.snapshot_contains("$ █ │$") + && remote_terminal.snapshot_contains("$ ") { + step_is_complete = true; + } + step_is_complete + }, + }) + .run_all_steps(); + assert_snapshot!(last_snapshot); +} diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index b53c3129d..053df477a 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -8,7 +8,10 @@ use ssh2::Session; use std::io::prelude::*; use std::net::TcpStream; +use std::path::Path; + const ZELLIJ_EXECUTABLE_LOCATION: &str = "/usr/src/zellij/x86_64-unknown-linux-musl/debug/zellij"; +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"; @@ -54,6 +57,38 @@ fn start_zellij(channel: &mut ssh2::Channel, session_name: Option<&String>) { 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(); + } + }; + channel.flush().unwrap(); +} + pub fn take_snapshot(terminal_output: &mut TerminalPane) -> String { let output_lines = terminal_output.read_buffer_as_lines(); let cursor_coordinates = terminal_output.cursor_coordinates(); @@ -107,6 +142,20 @@ impl<'a> RemoteTerminal<'a> { pub fn snapshot_contains(&self, text: &str) -> bool { self.current_snapshot.contains(text) } + #[allow(unused)] + pub fn current_snapshot(&self) -> String { + // convenience method for writing tests, + // this should only be used when developing, + // please prefer "snapsht_contains" instead + self.current_snapshot.clone() + } + #[allow(unused)] + pub fn current_cursor_position(&self) -> String { + // convenience method for writing tests, + // this should only be used when developing, + // please prefer "cursor_position_is" instead + format!("x: {}, y: {}", self.cursor_x, self.cursor_y) + } pub fn send_key(&mut self, key: &[u8]) { self.channel.write(key).unwrap(); self.channel.flush().unwrap(); @@ -148,6 +197,7 @@ pub struct RemoteRunner { currently_running_step: Option, retries_left: usize, win_size: PositionAndSize, + layout_file_name: Option<&'static str>, } impl RemoteRunner { @@ -173,6 +223,39 @@ impl RemoteRunner { current_step_index: 0, retries_left: 3, win_size, + layout_file_name: None, + } + } + pub fn new_with_layout( + test_name: &'static str, + win_size: PositionAndSize, + layout_file_name: &'static str, + session_name: Option, + ) -> Self { + // let layout_file_name = local_layout_path.file_name().unwrap(); + let remote_path = Path::new(ZELLIJ_LAYOUT_PATH).join(layout_file_name); // TODO: not hardcoded + 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()); + setup_remote_environment(&mut channel, win_size); + start_zellij_with_layout( + &mut channel, + &remote_path.to_string_lossy(), + session_name.as_ref(), + ); + RemoteRunner { + steps: vec![], + channel, + terminal_output, + vte_parser, + session_name, + test_name, + currently_running_step: None, + current_step_index: 0, + retries_left: 3, + win_size, + layout_file_name: Some(layout_file_name), } } pub fn add_step(mut self, step: Step) -> Self { @@ -220,11 +303,25 @@ impl RemoteRunner { // inside the container format!("{}_{}", name, self.retries_left) }); - let mut new_runner = RemoteRunner::new(self.test_name, self.win_size, session_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() + 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, + ); + 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); + 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() + } } fn display_informative_error(&mut self) { let test_name = self.test_name; diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__accepts_basic_layout.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__accepts_basic_layout.snap new file mode 100644 index 000000000..5556153a5 --- /dev/null +++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__accepts_basic_layout.snap @@ -0,0 +1,29 @@ +--- +source: src/tests/e2e/cases.rs +expression: last_snapshot + +--- +$ █ │$ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ + │ +───────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────── +$ + + + + diff --git a/src/tests/fakes.rs b/src/tests/fakes.rs deleted file mode 100644 index 8d11458b9..000000000 --- a/src/tests/fakes.rs +++ /dev/null @@ -1,329 +0,0 @@ -use std::collections::{HashMap, VecDeque}; -use std::io::Write; -use std::os::unix::io::RawFd; -use std::path::PathBuf; -use std::sync::{Arc, Condvar, Mutex}; -use std::time::{Duration, Instant}; - -use zellij_utils::{nix, zellij_tile}; - -use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes}; -use crate::tests::utils::commands::{QUIT, SLEEP}; -use zellij_client::os_input_output::ClientOsApi; -use zellij_server::os_input_output::{async_trait, AsyncReader, Pid, ServerOsApi}; -use zellij_tile::data::Palette; -use zellij_utils::{ - async_std, - channels::{self, ChannelWithContext, SenderWithContext}, - errors::ErrorContext, - interprocess::local_socket::LocalSocketStream, - ipc::{ClientToServerMsg, ServerToClientMsg}, - pane_size::PositionAndSize, - shared::default_palette, -}; - -const MIN_TIME_BETWEEN_SNAPSHOTS: Duration = Duration::from_millis(150); - -#[derive(Clone)] -pub enum IoEvent { - Kill(Pid), - SetTerminalSizeUsingFd(RawFd, u16, u16), - IntoRawMode(RawFd), - UnsetRawMode(RawFd), - TcDrain(RawFd), -} - -#[derive(Clone)] -pub struct FakeStdoutWriter { - output_buffer: Arc>>, - pub output_frames: Arc>>>, - last_snapshot_time: Arc>, -} - -impl FakeStdoutWriter { - pub fn new(last_snapshot_time: Arc>) -> Self { - FakeStdoutWriter { - output_buffer: Arc::new(Mutex::new(Vec::new())), - output_frames: Arc::new(Mutex::new(Vec::new())), - last_snapshot_time, - } - } -} - -impl Write for FakeStdoutWriter { - fn write(&mut self, buf: &[u8]) -> Result { - let mut output_buffer = self.output_buffer.lock().unwrap(); - output_buffer.extend_from_slice(buf); - Ok(buf.len()) - } - fn flush(&mut self) -> Result<(), std::io::Error> { - let mut output_buffer = self.output_buffer.lock().unwrap(); - let mut output_frames = self.output_frames.lock().unwrap(); - let new_frame = output_buffer.drain(..).collect(); - output_frames.push(new_frame); - let mut last_snapshot_time = self.last_snapshot_time.lock().unwrap(); - *last_snapshot_time = Instant::now(); - Ok(()) - } -} - -#[derive(Clone)] -pub struct FakeInputOutput { - read_buffers: Arc>>, - input_to_add: Arc>>>, - stdin_commands: Arc>>>, - stdin_writes: Arc>>>, - pub stdout_writer: FakeStdoutWriter, // stdout_writer.output is already an arc/mutex - io_events: Arc>>, - win_sizes: Arc>>, - possible_tty_inputs: HashMap, - last_snapshot_time: Arc>, - send_instructions_to_client: SenderWithContext, - receive_instructions_from_server: - Arc>>, - send_instructions_to_server: SenderWithContext, - receive_instructions_from_client: - Arc>>, - should_trigger_sigwinch: Arc<(Mutex, Condvar)>, - sigwinch_event: Option, -} - -impl FakeInputOutput { - pub fn new(winsize: PositionAndSize) -> Self { - let mut win_sizes = HashMap::new(); - let last_snapshot_time = Arc::new(Mutex::new(Instant::now())); - let stdout_writer = FakeStdoutWriter::new(last_snapshot_time.clone()); - let (client_sender, client_receiver): ChannelWithContext = - channels::unbounded(); - let send_instructions_to_client = SenderWithContext::new(client_sender); - let (server_sender, server_receiver): ChannelWithContext = - channels::unbounded(); - let send_instructions_to_server = SenderWithContext::new(server_sender); - win_sizes.insert(0, winsize); // 0 is the current terminal - FakeInputOutput { - read_buffers: Arc::new(Mutex::new(HashMap::new())), - stdin_writes: Arc::new(Mutex::new(HashMap::new())), - input_to_add: Arc::new(Mutex::new(None)), - stdin_commands: Arc::new(Mutex::new(VecDeque::new())), - stdout_writer, - last_snapshot_time, - io_events: Arc::new(Mutex::new(vec![])), - win_sizes: Arc::new(Mutex::new(win_sizes)), - possible_tty_inputs: get_possible_tty_inputs(), - receive_instructions_from_client: Arc::new(Mutex::new(server_receiver)), - send_instructions_to_server, - receive_instructions_from_server: Arc::new(Mutex::new(client_receiver)), - send_instructions_to_client, - should_trigger_sigwinch: Arc::new((Mutex::new(false), Condvar::new())), - sigwinch_event: None, - } - } - pub fn with_tty_inputs(mut self, tty_inputs: HashMap) -> Self { - self.possible_tty_inputs = tty_inputs; - self - } - pub fn add_terminal_input(&mut self, input: &[&[u8]]) { - let stdin_commands = input.iter().map(|i| i.to_vec()).collect(); - self.stdin_commands = Arc::new(Mutex::new(stdin_commands)); - } - pub fn add_terminal(&self, fd: RawFd) { - self.stdin_writes.lock().unwrap().insert(fd, vec![]); - } - pub fn add_sigwinch_event(&mut self, new_position_and_size: PositionAndSize) { - self.sigwinch_event = Some(new_position_and_size); - } -} - -impl ClientOsApi for FakeInputOutput { - fn get_terminal_size_using_fd(&self, pid: RawFd) -> PositionAndSize { - if let Some(new_position_and_size) = self.sigwinch_event { - let (lock, _cvar) = &*self.should_trigger_sigwinch; - let should_trigger_sigwinch = lock.lock().unwrap(); - if *should_trigger_sigwinch && pid == 0 { - return new_position_and_size; - } - } - let win_sizes = self.win_sizes.lock().unwrap(); - let winsize = win_sizes.get(&pid).unwrap(); - *winsize - } - fn set_raw_mode(&mut self, pid: RawFd) { - self.io_events - .lock() - .unwrap() - .push(IoEvent::IntoRawMode(pid)); - } - fn unset_raw_mode(&self, pid: RawFd) { - self.io_events - .lock() - .unwrap() - .push(IoEvent::UnsetRawMode(pid)); - } - fn box_clone(&self) -> Box { - Box::new((*self).clone()) - } - fn read_from_stdin(&self) -> Vec { - loop { - let last_snapshot_time = { *self.last_snapshot_time.lock().unwrap() }; - if last_snapshot_time.elapsed() > MIN_TIME_BETWEEN_SNAPSHOTS { - break; - } else { - ::std::thread::sleep(MIN_TIME_BETWEEN_SNAPSHOTS - last_snapshot_time.elapsed()); - } - } - let command = self - .stdin_commands - .lock() - .unwrap() - .pop_front() - .unwrap_or(vec![]); - if command == SLEEP { - std::thread::sleep(std::time::Duration::from_millis(200)); - } else if command == QUIT && self.sigwinch_event.is_some() { - let (lock, cvar) = &*self.should_trigger_sigwinch; - { - let mut should_trigger_sigwinch = lock.lock().unwrap(); - *should_trigger_sigwinch = true; - } - cvar.notify_one(); - ::std::thread::sleep(MIN_TIME_BETWEEN_SNAPSHOTS); // give some time for the app to resize before quitting - } else if command == QUIT { - ::std::thread::sleep(MIN_TIME_BETWEEN_SNAPSHOTS); - } - command - } - fn get_stdout_writer(&self) -> Box { - Box::new(self.stdout_writer.clone()) - } - fn send_to_server(&self, msg: ClientToServerMsg) { - self.send_instructions_to_server.send(msg).unwrap(); - } - fn recv_from_server(&self) -> (ServerToClientMsg, ErrorContext) { - self.receive_instructions_from_server - .lock() - .unwrap() - .recv() - .unwrap() - } - fn handle_signals(&self, sigwinch_cb: Box, _quit_cb: Box) { - if self.sigwinch_event.is_some() { - let (lock, cvar) = &*self.should_trigger_sigwinch; - { - let mut should_trigger_sigwinch = lock.lock().unwrap(); - while !*should_trigger_sigwinch { - should_trigger_sigwinch = cvar.wait(should_trigger_sigwinch).unwrap(); - } - } - sigwinch_cb(); - } - } - fn connect_to_server(&self, _path: &std::path::Path) {} - fn load_palette(&self) -> Palette { - default_palette() - } -} - -struct FakeAsyncReader { - fd: RawFd, - os_api: Box, -} - -#[async_trait] -impl AsyncReader for FakeAsyncReader { - async fn read(&mut self, buf: &mut [u8]) -> Result { - // simulates async semantics: EAGAIN is not propagated to caller - loop { - let res = self.os_api.read_from_tty_stdout(self.fd, buf); - match res { - Err(nix::Error::Sys(nix::errno::Errno::EAGAIN)) => { - async_std::task::sleep(Duration::from_millis(10)).await; - continue; - } - Err(e) => { - break Err(std::io::Error::from_raw_os_error( - e.as_errno().unwrap() as i32 - )) - } - Ok(n_bytes) => break Ok(n_bytes), - } - } - } -} - -impl ServerOsApi for FakeInputOutput { - fn set_terminal_size_using_fd(&self, pid: RawFd, cols: u16, rows: u16) { - let terminal_input = self - .possible_tty_inputs - .get(&cols) - .expect(&format!("could not find input for size {:?}", cols)); - self.read_buffers - .lock() - .unwrap() - .insert(pid, terminal_input.clone()); - self.io_events - .lock() - .unwrap() - .push(IoEvent::SetTerminalSizeUsingFd(pid, cols, rows)); - } - fn spawn_terminal(&self, _file_to_open: Option) -> (RawFd, Pid) { - let next_terminal_id = self.stdin_writes.lock().unwrap().keys().len() as RawFd + 1; - self.add_terminal(next_terminal_id); - ( - next_terminal_id as i32, - Pid::from_raw(next_terminal_id + 1000), - ) // secondary number is arbitrary here - } - fn write_to_tty_stdin(&self, pid: RawFd, buf: &[u8]) -> Result { - let mut stdin_writes = self.stdin_writes.lock().unwrap(); - let write_buffer = stdin_writes.get_mut(&pid).unwrap(); - Ok(write_buffer.write(buf).unwrap()) - } - fn read_from_tty_stdout(&self, pid: RawFd, mut buf: &mut [u8]) -> Result { - let mut read_buffers = self.read_buffers.lock().unwrap(); - match read_buffers.get_mut(&pid) { - Some(bytes) => { - let available_range = bytes.read_position..bytes.content.len(); - let len = buf.write(&bytes.content[available_range]).unwrap(); - if len > bytes.read_position { - bytes.set_read_position(len); - } - return Ok(len); - } - None => Err(nix::Error::Sys(nix::errno::Errno::EAGAIN)), - } - } - fn async_file_reader(&self, fd: RawFd) -> Box { - Box::new(FakeAsyncReader { - fd, - os_api: ServerOsApi::box_clone(self), - }) - } - fn tcdrain(&self, pid: RawFd) -> Result<(), nix::Error> { - self.io_events.lock().unwrap().push(IoEvent::TcDrain(pid)); - Ok(()) - } - fn box_clone(&self) -> Box { - Box::new((*self).clone()) - } - fn kill(&self, pid: Pid) -> Result<(), nix::Error> { - self.io_events.lock().unwrap().push(IoEvent::Kill(pid)); - Ok(()) - } - fn recv_from_client(&self) -> (ClientToServerMsg, ErrorContext) { - self.receive_instructions_from_client - .lock() - .unwrap() - .recv() - .unwrap() - } - fn send_to_client(&self, msg: ServerToClientMsg) { - self.send_instructions_to_client.send(msg).unwrap(); - } - fn add_client_sender(&self) {} - fn remove_client_sender(&self) {} - fn send_to_temp_client(&self, _msg: ServerToClientMsg) {} - fn update_receiver(&mut self, _stream: LocalSocketStream) {} - fn load_palette(&self) -> Palette { - default_palette() - } -} diff --git a/src/tests/integration/basic.rs b/src/tests/integration/basic.rs deleted file mode 100644 index 98f77988d..000000000 --- a/src/tests/integration/basic.rs +++ /dev/null @@ -1,498 +0,0 @@ -use ::insta::assert_snapshot; -use zellij_utils::pane_size::PositionAndSize; - -use crate::tests::fakes::FakeInputOutput; -use crate::tests::start; -use crate::tests::utils::commands::{ - BRACKETED_PASTE_END, BRACKETED_PASTE_START, PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE, - SCROLL_MODE, SCROLL_PAGE_DOWN_IN_SCROLL_MODE, SCROLL_PAGE_UP_IN_SCROLL_MODE, - SCROLL_UP_IN_SCROLL_MODE, SPAWN_TERMINAL_IN_PANE_MODE, SPLIT_DOWN_IN_PANE_MODE, - SPLIT_RIGHT_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE, -}; -use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}; -use crate::CliArgs; -use zellij_utils::input::config::Config; - -fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput { - FakeInputOutput::new(fake_win_size.clone()) -} - -#[test] -pub fn starts_with_one_terminal() { - let fake_win_size = PositionAndSize { - cols: 121, - rows: 20, - x: 0, - y: 0, - ..Default::default() - }; - 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(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); - let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); - let snapshot_before_quit = - get_next_to_last_snapshot(snapshots).expect("could not find snapshot"); - assert_snapshot!(snapshot_before_quit); -} - -#[test] -pub fn split_terminals_vertically() { - let fake_win_size = PositionAndSize { - cols: 121, - rows: 20, - x: 0, - y: 0, - ..Default::default() - }; - 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(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); - let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); - let snapshot_before_quit = - get_next_to_last_snapshot(snapshots).expect("could not find snapshot"); - assert_snapshot!(snapshot_before_quit); -} - -#[test] -pub fn split_terminals_horizontally() { - let fake_win_size = PositionAndSize { - cols: 121, - rows: 20, - x: 0, - y: 0, - ..Default::default() - }; - 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(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); - let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); - let snapshot_before_quit = - get_next_to_last_snapshot(snapshots).expect("could not find snapshot"); - assert_snapshot!(snapshot_before_quit); -} - -#[test] -pub fn split_largest_terminal() { - // this finds the largest pane and splits along its longest edge (vertically or horizontally) - let fake_win_size = PositionAndSize { - cols: 121, - rows: 20, - x: 0, - y: 0, - ..Default::default() - }; - 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, - &SPAWN_TERMINAL_IN_PANE_MODE, - &SPAWN_TERMINAL_IN_PANE_MODE, - &QUIT, - ]); - start( - Box::new(fake_input_output.clone()), - CliArgs::default(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); - let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); - let snapshot_before_quit = - get_next_to_last_snapshot(snapshots).expect("could not find snapshot"); - assert_snapshot!(snapshot_before_quit); -} - -#[test] -pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() { - let fake_win_size = PositionAndSize { - cols: 8, - rows: 20, - x: 0, - y: 0, - ..Default::default() - }; - 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(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); - let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); - let snapshot_before_quit = - get_next_to_last_snapshot(snapshots).expect("could not find snapshot"); - assert_snapshot!(snapshot_before_quit); -} - -#[test] -pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() { - let fake_win_size = PositionAndSize { - cols: 121, - rows: 4, - x: 0, - y: 0, - ..Default::default() - }; - 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(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); - let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); - let snapshot_before_quit = - get_next_to_last_snapshot(snapshots).expect("could not find snapshot"); - assert_snapshot!(snapshot_before_quit); -} - -#[test] -pub fn cannot_split_largest_terminal_when_there_is_no_room() { - let fake_win_size = PositionAndSize { - cols: 8, - rows: 4, - x: 0, - y: 0, - ..Default::default() - }; - 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(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); - let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size); - let snapshot_before_quit = - get_next_to_last_snapshot(snapshots).expect("could not find snapshot"); - assert_snapshot!(snapshot_before_quit); -} - -#[test] -pub fn scrolling_up_inside_a_pane() { - let fake_win_size = PositionAndSize { - cols: 121, - rows: 20, - x: 0, - y: 0, - ..Default::default() - }; - 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, - &SPLIT_RIGHT_IN_PANE_MODE, - &SCROLL_MODE, - &SCROLL_UP_IN_SCROLL_MODE, - &SCROLL_UP_IN_SCROLL_MODE, - &QUIT, - ]); - start( - Box::new(fake_input_output.clone()), - CliArgs::default(), - Box::new(fake_input_output.clone()), - Config::default(), - None, - ); - let output_frames = fake_input_output - .stdout_writer - .output_frames - .lock() - .unwrap(); -