From c86307864f40da4a4ca69e9678695e02015c17b6 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 9 Sep 2017 17:50:23 +0200 Subject: [PATCH] =?utf8?q?t/265-swap:=20don=E2=80=99t=20start=20new=20i3?= =?utf8?q?=20instances=20with=20the=20same=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit $config is never touched after being initially set up. Not restarting i3 between each test case reduces the runtime of this test by an order of magnitude. --- testcases/t/265-swap.t | 47 ++++-------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/testcases/t/265-swap.t b/testcases/t/265-swap.t index 92988187..2927a622 100644 --- a/testcases/t/265-swap.t +++ b/testcases/t/265-swap.t @@ -32,26 +32,24 @@ my ($nodes, $expected_focus, $A, $B, $F); my ($result); my @urgent; +$pid = launch_with_config($config); + ############################################################################### # Invalid con_id should not crash i3 # See issue #2895. ############################################################################### -$pid = launch_with_config($config); $ws = fresh_workspace; open_window; cmd "swap container with con_id 1"; does_i3_live; -exit_gracefully($pid); ############################################################################### # Swap 2 windows in different workspaces using con_id ############################################################################### -$pid = launch_with_config($config); - $ws = fresh_workspace; open_window; $A = get_focused($ws); @@ -62,8 +60,6 @@ open_window; cmd "swap container with con_id $A"; is(get_focused($ws), $A, 'A is now focused'); -exit_gracefully($pid); - ############################################################################### # Swap two containers next to each other. # Focus should stay on B because both windows are on the focused workspace. @@ -73,7 +69,6 @@ exit_gracefully($pid); # | A | B | Focus Stacks: # +---+---+ H1: B, A ############################################################################### -$pid = launch_with_config($config); $ws = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -87,8 +82,6 @@ is($nodes->[0]->{window}, $B->{id}, 'B is on the left'); is($nodes->[1]->{window}, $A->{id}, 'A is on the right'); is(get_focused($ws), $expected_focus, 'B is still focused'); -exit_gracefully($pid); - ############################################################################### # Swap two containers with different parents. # In this test, the focus head of the left v-split container is A. @@ -100,7 +93,6 @@ exit_gracefully($pid); # | Y | B | V1: A, Y # +---+---+ V2: B, X ############################################################################### -$pid = launch_with_config($config); $ws = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -120,8 +112,6 @@ is($nodes->[0]->{nodes}->[0]->{window}, $B->{id}, 'B is on the top left'); is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right'); is(get_focused($ws), $expected_focus, 'B is still focused'); -exit_gracefully($pid); - ############################################################################### # Swap two containers with different parents. # In this test, the focus head of the left v-split container is _not_ A. @@ -133,7 +123,6 @@ exit_gracefully($pid); # | Y | B | V1: Y, A # +---+---+ V2: B, X ############################################################################### -$pid = launch_with_config($config); $ws = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -153,8 +142,6 @@ is($nodes->[0]->{nodes}->[0]->{window}, $B->{id}, 'B is on the top left'); is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right'); is(get_focused($ws), $expected_focus, 'B is still focused'); -exit_gracefully($pid); - ############################################################################### # Swap two containers with one being on a different workspace. # The focused container is B. @@ -171,8 +158,6 @@ exit_gracefully($pid); # | Y | B | Focus Stacks: # +---+---+ H2: B, Y ############################################################################### -$pid = launch_with_config($config); - $ws1 = fresh_workspace; $A = open_window(wm_class => 'mark_A'); $expected_focus = get_focused($ws1); @@ -192,8 +177,6 @@ $nodes = get_ws_content($ws2); is($nodes->[1]->{window}, $A->{id}, 'A is on ws2:right'); is(get_focused($ws2), $expected_focus, 'A is focused'); -exit_gracefully($pid); - ############################################################################### # Swap two non-focused containers within the same workspace. # @@ -203,7 +186,6 @@ exit_gracefully($pid); # | X | B | V1: A, X # +---+---+ V2: F, B ############################################################################### -$pid = launch_with_config($config); $ws = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -223,8 +205,6 @@ is($nodes->[0]->{nodes}->[0]->{window}, $B->{id}, 'B is on the top left'); is($nodes->[1]->{nodes}->[1]->{window}, $A->{id}, 'A is on the bottom right'); is(get_focused($ws), $expected_focus, 'F is still focused'); -exit_gracefully($pid); - ############################################################################### # Swap two non-focused containers which are both on different workspaces. # @@ -244,8 +224,6 @@ exit_gracefully($pid); # | F | # +---+ ############################################################################### -$pid = launch_with_config($config); - $ws1 = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -266,8 +244,6 @@ is($nodes->[0]->{window}, $A->{id}, 'A is on the second workspace'); is(get_focused($ws3), $expected_focus, 'F is still focused'); -exit_gracefully($pid); - ############################################################################### # Swap two non-focused containers with one being on a different workspace. # @@ -283,7 +259,6 @@ exit_gracefully($pid); # | B | F | Focus Stacks: # +---+---+ H2: F, B ############################################################################### -$pid = launch_with_config($config); $ws1 = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -302,8 +277,6 @@ $nodes = get_ws_content($ws2); is($nodes->[0]->{window}, $A->{id}, 'A is on the left of the second workspace'); is(get_focused($ws2), $expected_focus, 'F is still focused'); -exit_gracefully($pid); - ############################################################################### # 1. A container cannot be swapped with its parent. # 2. A container cannot be swapped with one of its children. @@ -315,8 +288,6 @@ exit_gracefully($pid); # | | B | # +---+---+ ############################################################################### -$pid = launch_with_config($config); - $ws = fresh_workspace; open_window; open_window; @@ -330,8 +301,6 @@ is($result->[0]->{success}, 0, 'B cannot be swappd with its parent'); $result = cmd '[con_mark=A] swap container with mark B'; is($result->[0]->{success}, 0, 'A cannot be swappd with one of its children'); -exit_gracefully($pid); - ############################################################################### # Swapping two containers preserves the geometry of the container they are # being swapped with. @@ -346,8 +315,6 @@ exit_gracefully($pid); # | B | A | # +---+-------+ ############################################################################### -$pid = launch_with_config($config); - $ws = fresh_workspace; $A = open_window(wm_class => 'mark_A'); $B = open_window(wm_class => 'mark_B'); @@ -364,8 +331,6 @@ $nodes = get_ws_content($ws); cmp_float($nodes->[0]->{percent}, 0.25, 'B has 25% width'); cmp_float($nodes->[1]->{percent}, 0.75, 'A has 75% width'); -exit_gracefully($pid); - ############################################################################### # Swapping containers not sharing the same parent preserves the geometry of # the container they are swapped with. @@ -388,7 +353,6 @@ exit_gracefully($pid); # | | X | # +---+-----+ ############################################################################### -$pid = launch_with_config($config); $ws = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -411,12 +375,9 @@ $nodes = get_ws_content($ws); cmp_float($nodes->[0]->{nodes}->[0]->{percent}, 0.25, 'B has 25% height'); cmp_float($nodes->[1]->{nodes}->[0]->{percent}, 0.75, 'A has 75% height'); -exit_gracefully($pid); - ############################################################################### # Swapping containers moves the urgency hint correctly. ############################################################################### -$pid = launch_with_config($config); $ws1 = fresh_workspace; $A = open_window(wm_class => 'mark_A'); @@ -437,8 +398,8 @@ is(get_ws($ws1)->{urgent}, 1, 'the first workspace is marked urgent'); is(@urgent, 0, 'A is not marked urgent'); is(get_ws($ws2)->{urgent}, 0, 'the second workspace is not marked urgent'); -exit_gracefully($pid); - ############################################################################### +exit_gracefully($pid); + done_testing; -- 2.39.5