From 53e7f187108e61724a080a0dfd0e5bfa37cf9290 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 14 Sep 2017 11:44:49 +0200 Subject: [PATCH 1/4] =?UTF-8?q?i3test::XTEST:=20don=E2=80=99t=20=E2=80=9Cu?= =?UTF-8?q?se=20i3test=E2=80=9D=20to=20avoid=20clobbering=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the $i3_autostart variable was accidentally overridden. --- testcases/lib/i3test.pm.in | 9 +-------- testcases/lib/i3test/Util.pm | 23 +++++++++++++++++++++++ testcases/lib/i3test/XTEST.pm | 3 ++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/testcases/lib/i3test.pm.in b/testcases/lib/i3test.pm.in index 5e3f8b2d..0f28a7a9 100644 --- a/testcases/lib/i3test.pm.in +++ b/testcases/lib/i3test.pm.in @@ -793,14 +793,7 @@ sub get_socket_path { if ($cache && defined($_cached_socket_path)) { return $_cached_socket_path; } - - my $atom = $x->atom(name => 'I3_SOCKET_PATH'); - my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256); - my $reply = $x->get_property_reply($cookie->{sequence}); - my $socketpath = $reply->{value}; - if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") { - $socketpath .= '-activation'; - } + my $socketpath = i3test::Util::get_socket_path($x); $_cached_socket_path = $socketpath; return $socketpath; } diff --git a/testcases/lib/i3test/Util.pm b/testcases/lib/i3test/Util.pm index 74913681..725ca4e1 100644 --- a/testcases/lib/i3test/Util.pm +++ b/testcases/lib/i3test/Util.pm @@ -5,9 +5,13 @@ use strict; use warnings; use v5.10; +use X11::XCB qw(GET_PROPERTY_TYPE_ANY); +use X11::XCB::Connection; + use Exporter qw(import); our @EXPORT = qw( slurp + get_socket_path ); =encoding utf-8 @@ -38,6 +42,25 @@ sub slurp { return $content; } +=head2 get_socket_path([X11::XCB::Connection]) + +Gets the socket path from the C atom stored on the X11 root +window. + +=cut +sub get_socket_path { + my ($x) = @_; + $x //= X11::XCB::Connection->new(); + my $atom = $x->atom(name => 'I3_SOCKET_PATH'); + my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256); + my $reply = $x->get_property_reply($cookie->{sequence}); + my $socketpath = $reply->{value}; + if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") { + $socketpath .= '-activation'; + } + return $socketpath; +} + =head1 AUTHOR Michael Stapelberg diff --git a/testcases/lib/i3test/XTEST.pm b/testcases/lib/i3test/XTEST.pm index 3937b70a..b7a9cdc5 100644 --- a/testcases/lib/i3test/XTEST.pm +++ b/testcases/lib/i3test/XTEST.pm @@ -5,7 +5,8 @@ use strict; use warnings; use v5.10; -use i3test i3_autostart => 0; +use Test::More; +use i3test::Util qw(get_socket_path); use lib qw(@abs_top_srcdir@/AnyEvent-I3/blib/lib); use AnyEvent::I3; use ExtUtils::PkgConfig; From 02786155dc7f5962242681f53383a54230f76965 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 14 Sep 2017 12:30:42 +0200 Subject: [PATCH 2/4] tests: use i3_config arg instead of precisely one launch_with_config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way, tests are shorter, and i3test’s invocation of launch_with_config parallelizes work better, using dont_block => 1. --- testcases/lib/SocketActivation.pm | 5 ++ testcases/lib/i3test.pm.in | 5 +- testcases/t/156-fullscreen-focus.t | 18 ++----- testcases/t/186-regress-assign-focus-parent.t | 8 +-- testcases/t/199-ipc-mode-event.t | 8 +-- testcases/t/200-urgency-timer.t | 13 +---- testcases/t/207-shmlog.t | 14 ++---- testcases/t/208-regress-floating-criteria.t | 8 +-- testcases/t/211-regress-urgency-assign.t | 17 +++---- testcases/t/222-regress-dock-resize.t | 11 +---- testcases/t/230-floating-fullscreen-restart.t | 7 +-- .../t/233-regress-manage-focus-unmapped.t | 8 +-- testcases/t/237-regress-assign-focus.t | 8 +-- testcases/t/241-consistent-center.t | 8 +-- ...244-new-workspace-floating-enable-center.t | 8 +-- testcases/t/248-regress-urgency-clear.t | 18 +++---- .../t/254-move-to-output-with-criteria.t | 8 +-- testcases/t/257-keypress-group1-fallback.t | 21 +++----- testcases/t/258-keypress-release.t | 18 +++---- .../t/263-config-reload-reverts-bind-mode.t | 8 +-- testcases/t/264-dock-criteria.t | 7 +-- testcases/t/271-for_window_tilingfloating.t | 17 +++---- testcases/t/272-regress-focus-assign.t | 16 ++---- .../t/279-regress-default-floating-border.t | 8 +-- testcases/t/280-wm-class-change-handler.t | 10 +--- testcases/t/281-regress-reload-bindsym.t | 11 +---- .../t/282-tabbed-floating-disable-crash.t | 8 +-- testcases/t/286-root-window-mouse-binding.t | 9 +--- testcases/t/291-swap.t | 9 +--- testcases/t/500-multi-monitor.t | 6 +-- testcases/t/501-scratchpad.t | 9 +--- testcases/t/502-focus-output.t | 9 +--- testcases/t/503-workspace.t | 7 +-- testcases/t/504-move-workspace-to-output.t | 12 ++--- testcases/t/505-scratchpad-resolution.t | 9 +--- testcases/t/507-workspace-move-crash.t | 11 +---- testcases/t/509-workspace_layout.t | 9 +--- testcases/t/510-focus-across-outputs.t | 11 +---- .../t/511-scratchpad-configure-request.t | 12 +---- testcases/t/512-move-wraps.t | 12 +---- testcases/t/513-move-workspace.t | 14 +----- testcases/t/514-ipc-workspace-multi-monitor.t | 12 +---- testcases/t/515-create-workspace.t | 7 +-- testcases/t/516-move.t | 14 ++---- testcases/t/517-regress-move-direction-ipc.t | 8 +-- testcases/t/518-interpret-workspace-numbers.t | 7 +-- testcases/t/519-mouse-warping.t | 15 ++---- .../t/520-regress-focus-direction-floating.t | 8 +-- testcases/t/521-ewmh-desktop-viewport.t | 8 +-- testcases/t/522-rename-assigned-workspace.t | 7 +-- testcases/t/523-move-position-center.t | 8 +-- testcases/t/524-move.t | 8 +-- testcases/t/525-i3bar-mouse-bindings.t | 49 +++++++++++++------ testcases/t/526-reconfigure-dock.t | 19 +++---- .../t/528-workspace-next-prev-reversed.t | 17 +++---- testcases/t/529-net-wm-desktop.t | 24 +++------ testcases/t/530-bug-2229.t | 8 +-- testcases/t/531-fullscreen-on-given-output.t | 10 +--- testcases/t/534-dont-warp.t | 12 +---- testcases/t/535-workspace-next-prev.t | 17 +++---- testcases/t/536-net-wm-desktop_mm.t | 32 +++++------- 61 files changed, 187 insertions(+), 538 deletions(-) diff --git a/testcases/lib/SocketActivation.pm b/testcases/lib/SocketActivation.pm index 5951fd26..5a5a4484 100644 --- a/testcases/lib/SocketActivation.pm +++ b/testcases/lib/SocketActivation.pm @@ -49,6 +49,11 @@ sub activate_i3 { die "could not fork()"; } if ($pid == 0) { + # Start a process group so that in the parent, we can kill the entire + # process group and immediately kill i3bar and any other child + # processes. + setpgrp; + $ENV{LISTEN_PID} = $$; $ENV{LISTEN_FDS} = 1; delete $ENV{DESKTOP_STARTUP_ID}; diff --git a/testcases/lib/i3test.pm.in b/testcases/lib/i3test.pm.in index 0f28a7a9..a9cfba37 100644 --- a/testcases/lib/i3test.pm.in +++ b/testcases/lib/i3test.pm.in @@ -126,7 +126,7 @@ END { exit_gracefully($i3_pid, "/tmp/nested-$ENV{DISPLAY}"); } else { - kill(9, $i3_pid) + kill(-9, $i3_pid) or $tester->BAIL_OUT("could not kill i3"); waitpid $i3_pid, 0; @@ -138,8 +138,9 @@ sub import { my $pkg = caller; $i3_autostart = delete($args{i3_autostart}) // 1; + my $i3_config = delete($args{i3_config}) // '-default'; - my $cv = launch_with_config('-default', dont_block => 1) + my $cv = launch_with_config($i3_config, dont_block => 1) if $i3_autostart; my $test_more_args = ''; diff --git a/testcases/t/156-fullscreen-focus.t b/testcases/t/156-fullscreen-focus.t index b337de9a..eefdac9f 100644 --- a/testcases/t/156-fullscreen-focus.t +++ b/testcases/t/156-fullscreen-focus.t @@ -18,22 +18,16 @@ # the time of launching the new one. Also make sure that focusing containers # in other workspaces work even when there is a fullscreen container. # -use i3test i3_autostart => 0; - -# Screen setup looks like this: -# +----+----+ -# | S1 | S2 | -# +----+----+ -my $config = < < 0; - -my $config = < < "testcase"); is_num_children('targetws', 3, 'new window opened next to last one'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/199-ipc-mode-event.t b/testcases/t/199-ipc-mode-event.t index 43f7b178..62675b44 100644 --- a/testcases/t/199-ipc-mode-event.t +++ b/testcases/t/199-ipc-mode-event.t @@ -15,9 +15,7 @@ # (unless you are already familiar with Perl) # # Verifies that the IPC 'mode' event is sent when modes are changed. -use i3test i3_autostart => 0; - -my $config = < <connect->recv; @@ -52,6 +48,4 @@ $t = AnyEvent->timer(after => 0.5, cb => sub { $cv->send(0); }); ok($cv->recv, 'Mode event received'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/200-urgency-timer.t b/testcases/t/200-urgency-timer.t index b6ebc876..bd0b4078 100644 --- a/testcases/t/200-urgency-timer.t +++ b/testcases/t/200-urgency-timer.t @@ -20,20 +20,13 @@ # use List::Util qw(first); -use i3test i3_autostart => 0; -use Time::HiRes qw(sleep); - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < < 0; +use i3test; use IPC::Run qw(run); use File::Temp; @@ -22,14 +22,8 @@ use File::Temp; # 1: test that shared memory logging does not work yet ################################################################################ -my $config = < 0; - -my $config = <<'EOT'; +use i3test i3_config => < 'Borderless window', wm_class => 'special', @@ -43,6 +39,4 @@ cmd '[class="^special$"] focus'; does_i3_live; -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/211-regress-urgency-assign.t b/testcases/t/211-regress-urgency-assign.t index 57d8b434..1e1df7be 100644 --- a/testcases/t/211-regress-urgency-assign.t +++ b/testcases/t/211-regress-urgency-assign.t @@ -20,7 +20,12 @@ # # Ticket: #1086 # Bug still in: 4.6-62-g7098ef6 -use i3test i3_autostart => 0; +use i3test i3_config => < 0, my @urgent = grep { $_->{urgent} } @{get_ws_content('nonvisible')}; isnt(@urgent, 0, 'urgent window(s) found on destination workspace'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/222-regress-dock-resize.t b/testcases/t/222-regress-dock-resize.t index b9f9a797..bfd7aa4b 100644 --- a/testcases/t/222-regress-dock-resize.t +++ b/testcases/t/222-regress-dock-resize.t @@ -18,18 +18,11 @@ # client. # Ticket: #1201 # Bug still in: 4.7.2-107-g9b03be6 -use i3test i3_autostart => 0; - -my $config = <<'EOT'; +use i3test i3_config => <connect()->recv; - my $window = open_window( wm_class => 'special', window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), @@ -39,6 +32,4 @@ cmd('[class="special"] resize grow height 160 px or 16 ppt'); does_i3_live; -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/230-floating-fullscreen-restart.t b/testcases/t/230-floating-fullscreen-restart.t index e4d51e2e..9d1ac70c 100644 --- a/testcases/t/230-floating-fullscreen-restart.t +++ b/testcases/t/230-floating-fullscreen-restart.t @@ -18,16 +18,13 @@ # and that they keep their geometry. # Ticket: #1263 # Bug still in: 4.7.2-200-g570b572 -use i3test i3_autostart => 0; - -my $config = < < '__i3-test-window'); @@ -46,6 +43,4 @@ $floating_win = $nodes->{floating_nodes}->[0]->{nodes}->[0]; is($floating_win->{fullscreen_mode}, 1, 'floating window still in fullscreen mode'); is_deeply($floating_win->{geometry}, $old_geometry, 'floating window geometry still the same'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/233-regress-manage-focus-unmapped.t b/testcases/t/233-regress-manage-focus-unmapped.t index 1b78f253..3f47970c 100644 --- a/testcases/t/233-regress-manage-focus-unmapped.t +++ b/testcases/t/233-regress-manage-focus-unmapped.t @@ -19,9 +19,7 @@ # which can lead to complications # Ticket: #1283 # Bug still in: 4.8-24-g60070de -use i3test i3_autostart => 0; - -my $config = <<'EOT'; +use i3test i3_config => <<'EOT'; # i3 config file (v4) font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 @@ -29,8 +27,6 @@ for_window [class="^special_kill$"] kill for_window [class="^special_scratchpad$"] move scratchpad EOT -my $pid = launch_with_config($config); - my $win = open_window; my $scratch_window = open_window( @@ -53,6 +49,4 @@ sync_with_i3; is($x->input_focus, $win->{id}, 'an assignment that kills a window should not disturb focus'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/237-regress-assign-focus.t b/testcases/t/237-regress-assign-focus.t index e9cb537e..e193c021 100644 --- a/testcases/t/237-regress-assign-focus.t +++ b/testcases/t/237-regress-assign-focus.t @@ -18,9 +18,7 @@ # assigned to an invisible workspace) will not crash i3. # Ticket: #1338 # Bug still in: 4.8-91-g294d52e -use i3test i3_autostart => 0; - -my $config = < < 0; - -my $config = < <rect; is($new->{x}, $child->{x}, 'x coordinates match'); is($new->{y}, $child->{y}, 'y coordinates match'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/244-new-workspace-floating-enable-center.t b/testcases/t/244-new-workspace-floating-enable-center.t index dbc9a80a..b1c7fca0 100644 --- a/testcases/t/244-new-workspace-floating-enable-center.t +++ b/testcases/t/244-new-workspace-floating-enable-center.t @@ -17,9 +17,7 @@ # Ensures that 'move workspace $new, floating enable' on a marked window # leaves the window centered on the new workspace. # Bug still in: 4.10.2-137-ga4f0ed6 -use i3test i3_autostart => 0; - -my $config = < <{x} + $pos->{width} / 2), int($x->root->rect->width / 2), is(int($pos->{y} + $pos->{height} / 2), int($x->root->rect->height / 2), 'y coordinates match'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/248-regress-urgency-clear.t b/testcases/t/248-regress-urgency-clear.t index 10ef3774..314a8511 100644 --- a/testcases/t/248-regress-urgency-clear.t +++ b/testcases/t/248-regress-urgency-clear.t @@ -18,7 +18,12 @@ # to focus_on_window_activation=urgent), hence the application not clearing it. # Ticket: #1825 # Bug still in: 4.10.3-253-g03799dd -use i3test i3_autostart => 0; +use i3test i3_config => <send_event(0, $x->get_root_window(), X11::XCB::EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg); } -my $config = <<'EOT'; -# i3 config file (v4) -font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 - -focus_on_window_activation urgent -EOT - -my $pid = launch_with_config($config); -my $i3 = i3(get_socket_path(0)); my $ws = fresh_workspace; my $first = open_window; my $second = open_window; @@ -64,6 +60,4 @@ cmd '[urgent=latest] focus'; sync_with_i3; is($x->input_focus, $second->id, 'second window still focused'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/254-move-to-output-with-criteria.t b/testcases/t/254-move-to-output-with-criteria.t index b27ded3e..7d8229dd 100644 --- a/testcases/t/254-move-to-output-with-criteria.t +++ b/testcases/t/254-move-to-output-with-criteria.t @@ -17,17 +17,13 @@ # Verifies that "move container to output" works correctly when # used with command criteria. # Bug still in: 4.10.4-349-gee5db87 -use i3test i3_autostart => 0; - -my $config = < < 0); my $ws_top_right = fresh_workspace(output => 1); my $ws_bottom_left = fresh_workspace(output => 2); @@ -45,6 +41,4 @@ is_num_children($ws_top_right, 1, 'one container on the upper right workspace'); is_num_children($ws_bottom_left, 0, 'no containers on the lower left workspace'); is_num_children($ws_bottom_right, 1, 'one container on the lower right workspace'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/257-keypress-group1-fallback.t b/testcases/t/257-keypress-group1-fallback.t index 843b8fe6..1c19cb78 100644 --- a/testcases/t/257-keypress-group1-fallback.t +++ b/testcases/t/257-keypress-group1-fallback.t @@ -19,7 +19,14 @@ # Ticket: #2062 # Bug still in: 4.11-103-gc8d51b4 # Bug introduced with commit 0e5180cae9e9295678e3f053042b559e82cb8c98 -use i3test i3_autostart => 0; +use i3test + i3_config => </dev/null|) != 0; -my $config = < 0; -use i3test::XTEST; -use ExtUtils::PkgConfig; - -SKIP: { - skip "libxcb-xkb too old (need >= 1.11)", 1 unless - ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11'); - -my $config = < <= 1.11)", 1 unless + ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11'); start_binding_capture; @@ -90,8 +86,6 @@ is(listen_for_binding( sync_with_i3; is(scalar @i3test::XTEST::binding_events, 4, 'Received exactly 4 binding events'); -exit_gracefully($pid); - } done_testing; diff --git a/testcases/t/263-config-reload-reverts-bind-mode.t b/testcases/t/263-config-reload-reverts-bind-mode.t index d72d3d94..549a862b 100644 --- a/testcases/t/263-config-reload-reverts-bind-mode.t +++ b/testcases/t/263-config-reload-reverts-bind-mode.t @@ -18,9 +18,7 @@ # binding mode. # Ticket: #2228 # Bug still in: 4.11-262-geb631ce -use i3test i3_autostart => 0; - -my $config = < <timer(after => 0.5, cb => sub { $cv->send(0); }); ok($cv->recv, 'Mode event received'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/264-dock-criteria.t b/testcases/t/264-dock-criteria.t index cbbdeb0f..d4b3b689 100644 --- a/testcases/t/264-dock-criteria.t +++ b/testcases/t/264-dock-criteria.t @@ -16,15 +16,11 @@ # # Verifies that command or config criteria does not match dock clients # Bug still in: 4.12-38-ge690e3d -use i3test i3_autostart => 0; - -my $config = < < 0; +use i3test i3_config => <{marks}, [ 'tiled' ], "mark set for 'tiling' criterion"); cmp_ok(@nodes, '==', 1, 'one floating container on this workspace'); is_deeply($nodes[0]->{nodes}[0]->{marks}, [ 'floated' ], "mark set for 'floating' criterion"); -exit_gracefully($pid); - ############################################################## done_testing; diff --git a/testcases/t/272-regress-focus-assign.t b/testcases/t/272-regress-focus-assign.t index b010963b..6b0aad0c 100644 --- a/testcases/t/272-regress-focus-assign.t +++ b/testcases/t/272-regress-focus-assign.t @@ -17,7 +17,11 @@ # Regression: Checks if focus is stolen when a window is managed which is # assigned to an invisible workspace # -use i3test i3_autostart => 0; +use i3test i3_config => <{focused}, 'current workspace still focused'); -exit_gracefully($pid); - $window->destroy; done_testing; diff --git a/testcases/t/279-regress-default-floating-border.t b/testcases/t/279-regress-default-floating-border.t index d5994f58..5563ec32 100644 --- a/testcases/t/279-regress-default-floating-border.t +++ b/testcases/t/279-regress-default-floating-border.t @@ -18,9 +18,7 @@ # not applied when the default tiling border is set to a pixel value. # Ticket: #1305 # Bug still in: 4.8-62-g7381b50 -use i3test i3_autostart => 0; - -my $config = < <{floating_nodes}}; is($floating[0]->{nodes}[0]->{border}, 'normal', 'default floating border is `normal`'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/280-wm-class-change-handler.t b/testcases/t/280-wm-class-change-handler.t index ce237b57..38b8351d 100644 --- a/testcases/t/280-wm-class-change-handler.t +++ b/testcases/t/280-wm-class-change-handler.t @@ -19,16 +19,12 @@ # in criteria selection # Ticket: #1052 # Bug still in: 4.8-73-g6bf7f8e -use i3test i3_autostart => 0; -use X11::XCB qw(PROP_MODE_REPLACE); - -my $config = < <{window_properties}->{class}, 'a', 'Non-null-terminated strings should be handled correctly'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/281-regress-reload-bindsym.t b/testcases/t/281-regress-reload-bindsym.t index 6d5d12c3..ad81244e 100644 --- a/testcases/t/281-regress-reload-bindsym.t +++ b/testcases/t/281-regress-reload-bindsym.t @@ -16,9 +16,7 @@ # # Test that the binding event works properly # Ticket: #1210 -use i3test i3_autostart => 0; - -my $config = < <connect->recv; - qx(xdotool key r); does_i3_live; - exit_gracefully($pid); - } done_testing; diff --git a/testcases/t/282-tabbed-floating-disable-crash.t b/testcases/t/282-tabbed-floating-disable-crash.t index 7947158c..b4f1a4c2 100644 --- a/testcases/t/282-tabbed-floating-disable-crash.t +++ b/testcases/t/282-tabbed-floating-disable-crash.t @@ -18,16 +18,12 @@ # unfocused window within a tabbed container. # Ticket: #1484 # Bug still in: 4.9.1-124-g856e1f9 -use i3test i3_autostart => 0; - -my $config = < < 0; -use i3test::XTEST; - -my $config = < < 0; - -my $config = < < 0; - -my $config = < <{name} } @{$tree->{nodes}}; is_deeply(\@outputs, [ '__i3', 'fake-0', 'fake-1' ], 'multi-monitor outputs ok'); -exit_gracefully($pid); done_testing; diff --git a/testcases/t/501-scratchpad.t b/testcases/t/501-scratchpad.t index 0f9b0df0..5aad2504 100644 --- a/testcases/t/501-scratchpad.t +++ b/testcases/t/501-scratchpad.t @@ -18,17 +18,12 @@ # ticket #596, bug present until up to commit # 89dded044b4fffe78f9d70778748fabb7ac533e9. # -use i3test i3_autostart => 0; - -my $config = < < 0); verify_scratchpad_switch($first, $second); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/502-focus-output.t b/testcases/t/502-focus-output.t index cf297f0e..4b6fac40 100644 --- a/testcases/t/502-focus-output.t +++ b/testcases/t/502-focus-output.t @@ -16,16 +16,13 @@ # # Verifies the 'focus output' command works properly. -use i3test i3_autostart => 0; -use List::Util qw(first); - -my $config = < < 0; - -my $config = < < to [output] ' command works # use List::Util qw(first); -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < < 0; - -my $config = < <root->warp_pointer(0, 0); @@ -84,6 +79,4 @@ sync_with_i3; my $third = fresh_workspace(output => 1); verify_scratchpad_doesnt_move($third); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/507-workspace-move-crash.t b/testcases/t/507-workspace-move-crash.t index 9e80553b..ed5a9005 100644 --- a/testcases/t/507-workspace-move-crash.t +++ b/testcases/t/507-workspace-move-crash.t @@ -19,19 +19,12 @@ # Bug still in: 4.3-78-g66b389c # use List::Util qw(first); -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < < 0; - -my $config = < <{workspace_layout}, 'tabbed', 'workspace layout is "tabbed"'); - -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/510-focus-across-outputs.t b/testcases/t/510-focus-across-outputs.t index afa0ddef..8097f73f 100644 --- a/testcases/t/510-focus-across-outputs.t +++ b/testcases/t/510-focus-across-outputs.t @@ -17,19 +17,12 @@ # Tests that switching workspaces via 'focus $dir' never leaves a floating # window focused. # -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < <input_focus, $second->id, 'second window focused'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/511-scratchpad-configure-request.t b/testcases/t/511-scratchpad-configure-request.t index 561d2435..851afb4a 100644 --- a/testcases/t/511-scratchpad-configure-request.t +++ b/testcases/t/511-scratchpad-configure-request.t @@ -17,21 +17,13 @@ # Tests that ConfigureRequests don’t make windows fall out of the scratchpad. # Ticket: #898 # Bug still in: 4.4-15-g770ead6 -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < < 0); my $right_ws = fresh_workspace(output => 1); @@ -49,6 +41,4 @@ is(scalar @{$ws->{floating_nodes}}, 0, 'scratchpad window still in scratchpad af $ws = get_ws($right_ws); is(scalar @{$ws->{floating_nodes}}, 0, 'scratchpad window still in scratchpad after ConfigureRequest'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/512-move-wraps.t b/testcases/t/512-move-wraps.t index 82d5a7cc..2c5a27af 100644 --- a/testcases/t/512-move-wraps.t +++ b/testcases/t/512-move-wraps.t @@ -18,21 +18,13 @@ # E.g. when you have a container on the right output and you move it to the # right, it should appear on the left output. # Bug still in: 4.4-106-g3cd4b8c -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < < 1); my $left = fresh_workspace(output => 0); @@ -51,6 +43,4 @@ cmd 'move container to output right'; is_num_children($left, 1, 'one container on left workspace'); is_num_children($right, 0, 'no containers on right workspace'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/513-move-workspace.t b/testcases/t/513-move-workspace.t index 3e27a6c0..fb9f0e25 100644 --- a/testcases/t/513-move-workspace.t +++ b/testcases/t/513-move-workspace.t @@ -15,21 +15,13 @@ # (unless you are already familiar with Perl) # # Tests whether moving workspaces between outputs works correctly. -use i3test i3_autostart => 0; -use List::Util qw(first); - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < <[1]->{window}, $win1->id, 'window 1 on workspace 5 after moving'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/514-ipc-workspace-multi-monitor.t b/testcases/t/514-ipc-workspace-multi-monitor.t index 61622ab0..f34ee233 100644 --- a/testcases/t/514-ipc-workspace-multi-monitor.t +++ b/testcases/t/514-ipc-workspace-multi-monitor.t @@ -17,20 +17,12 @@ # Ticket: #990 # Bug still in: 4.5.1-23-g82b5978 -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < <connect()->recv; @@ -73,6 +65,4 @@ ok($event, 'Workspace "focus" event received'); is($event->{current}->{id}, $current_ws->{id}, 'Event gave correct current workspace'); is($event->{old}->{id}, $old_ws->{id}, 'Event gave correct old workspace'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/515-create-workspace.t b/testcases/t/515-create-workspace.t index be790bf0..aad0693f 100644 --- a/testcases/t/515-create-workspace.t +++ b/testcases/t/515-create-workspace.t @@ -17,9 +17,7 @@ # Tests that new workspace names are taken from the config, # then from the first free number starting with 1. # -use i3test i3_autostart => 0; - -my $config = < <get_workspaces->recv; @@ -35,6 +32,4 @@ my $ws = $i3->get_workspaces->recv; is($ws->[0]->{name}, '1: eggs', 'new workspace uses config name'); is($ws->[1]->{name}, '2', 'naming continues with next free number'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/516-move.t b/testcases/t/516-move.t index 0d21ca31..3a4fa2ea 100644 --- a/testcases/t/516-move.t +++ b/testcases/t/516-move.t @@ -16,13 +16,7 @@ # # Tests if a simple 'move ' command will move containers across outputs. # -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < <root->warp_pointer(0, 0); ##################################################################### # Try to move a single window across outputs in each direction @@ -101,6 +97,4 @@ is(scalar @{get_ws_content('left-top')}, 1, 'moved some window to left-bottom wo $compare_window = shift @{get_ws_content('left-top')}; is($social_window->name, $compare_window->{name}, 'moved correct window to left-bottom workspace'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/517-regress-move-direction-ipc.t b/testcases/t/517-regress-move-direction-ipc.t index 383b2779..1a325ae7 100644 --- a/testcases/t/517-regress-move-direction-ipc.t +++ b/testcases/t/517-regress-move-direction-ipc.t @@ -18,9 +18,7 @@ # ipc event required for i3bar to be properly updated and redrawn. # # Bug still in: 4.6-195-g34232b8 -use i3test i3_autostart => 0; - -my $config = < <connect()->recv; @@ -78,6 +74,4 @@ ok($event, 'moving from workspace with one window triggered focus ipc event'); is($event->{current}->{name}, 'ws-right', 'focus event gave the right workspace'); is(@{$event->{current}->{nodes}}, 2, 'focus event gave the right number of windows on the workspace'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/518-interpret-workspace-numbers.t b/testcases/t/518-interpret-workspace-numbers.t index 577881f0..aa2e2a27 100644 --- a/testcases/t/518-interpret-workspace-numbers.t +++ b/testcases/t/518-interpret-workspace-numbers.t @@ -18,9 +18,7 @@ # assign any workspace of that number to the specified output. # Ticket: #1238 # Bug still in: 4.7.2-147-g3760a48 -use i3test i3_autostart => 0; - -my $config = < <connect->recv; @@ -72,6 +69,4 @@ is(get_output_for_workspace('1:override'), 'fake-0', 'Assignment rules should not be affected by the order assignments are declared') or diag 'Since workspace "1:override" is assigned by name to fake-0, it should open on fake-0'; -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/519-mouse-warping.t b/testcases/t/519-mouse-warping.t index 674f4cdb..5b7e2c17 100644 --- a/testcases/t/519-mouse-warping.t +++ b/testcases/t/519-mouse-warping.t @@ -11,21 +11,16 @@ # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf # (unless you are already familiar with Perl) -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < <root->warp_pointer(0, 0); ###################################################### # Open one workspace with one window on both outputs # @@ -47,6 +42,4 @@ $x->root->warp_pointer(0, 0); # Ensure focus is still on workspace 2 is(focused_ws, '2', 'warped mouse cursor to (0, 0), focus still in workspace 2'); -# Exit gracefully -exit_gracefully($pid); done_testing; diff --git a/testcases/t/520-regress-focus-direction-floating.t b/testcases/t/520-regress-focus-direction-floating.t index ccef49e7..871f8045 100644 --- a/testcases/t/520-regress-focus-direction-floating.t +++ b/testcases/t/520-regress-focus-direction-floating.t @@ -17,9 +17,7 @@ # Ensure that `focus [direction]` will focus an existing floating con when no # tiling con exists on the output in [direction] when focusing across outputs # Bug still in: 4.7.2-204-g893dbae -use i3test i3_autostart => 0; - -my $config = < <input_focus, $win->id, 'Focusing across outputs with `focus [direction]` should focus an existing floating con when no tiling con exists on the output in [direction].'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/521-ewmh-desktop-viewport.t b/testcases/t/521-ewmh-desktop-viewport.t index 9e36090c..27354769 100644 --- a/testcases/t/521-ewmh-desktop-viewport.t +++ b/testcases/t/521-ewmh-desktop-viewport.t @@ -18,9 +18,7 @@ # properly on the root window. We interpret this as a list of x/y coordinate # pairs for the upper left corner of the respective outputs of the workspaces # Ticket: #1241 -use i3test i3_autostart => 0; - -my $config = < < 0; - -my $config = < <connect->recv; @@ -85,6 +82,4 @@ cmd 'rename workspace to baz'; is(get_output_for_workspace('baz'), 'fake-1', 'Renaming the workspace to a number and name should move it to the assigned output'); - -exit_gracefully($pid); done_testing; diff --git a/testcases/t/523-move-position-center.t b/testcases/t/523-move-position-center.t index 6b584245..f0a8a816 100644 --- a/testcases/t/523-move-position-center.t +++ b/testcases/t/523-move-position-center.t @@ -18,9 +18,7 @@ # the appropriate output. # Ticket: #1211 # Bug still in: 4.9.1-108-g037cb31 -use i3test i3_autostart => 0; - -my $config = < <{floating_nodes}}, 0, 'no floating nodes on left ws'); is(scalar @{get_ws('right')->{floating_nodes}}, 1, 'one floating node on right ws'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/524-move.t b/testcases/t/524-move.t index 473bf235..8cc20bc0 100644 --- a/testcases/t/524-move.t +++ b/testcases/t/524-move.t @@ -19,9 +19,7 @@ # Ticket: #1603 # Bug still in: 4.10.1-40-g0ad097e use List::Util qw(first); -use i3test i3_autostart => 0; - -my $config = < < 0; -use i3test::XTEST; - -my ($cv, $timer); -sub reset_test { - $cv = AE::cv; - $timer = AE::timer(1, 0, sub { $cv->send(0); }); -} - -my $config = < <send(0); }); +} -my $pid = launch_with_config($config); my $i3 = i3(get_socket_path()); $i3->connect()->recv; my $ws = fresh_workspace; @@ -63,8 +60,32 @@ $i3->subscribe({ }, })->recv; -my $con = $cv->recv; -ok($con, 'i3bar appeared'); +my $con; + +sub i3bar_present { + my ($nodes) = @_; + + for my $node (@{$nodes}) { + my $props = $node->{window_properties}; + if (defined($props) && $props->{class} eq 'i3bar') { + return 1; + } + } + + return 0 if !@{$nodes}; + + my @children = (map { @{$_->{nodes}} } @{$nodes}, + map { @{$_->{'floating_nodes'}} } @{$nodes}); + + return i3bar_present(\@children); +} + +if (i3bar_present($i3->get_tree->recv->{nodes})) { + ok(1, 'i3bar present'); +} else { + $con = $cv->recv; + ok($con, 'i3bar appeared'); +} my $left = open_window; my $right = open_window; @@ -108,6 +129,4 @@ $con = $cv->recv; is($con->{window}, $left->{id}, 'button 5 moves focus left'); reset_test; -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/526-reconfigure-dock.t b/testcases/t/526-reconfigure-dock.t index 9e3ed3f2..19887ac1 100644 --- a/testcases/t/526-reconfigure-dock.t +++ b/testcases/t/526-reconfigure-dock.t @@ -16,9 +16,14 @@ # # Test reconfiguration of dock clients. # Ticket: #1883 -use i3test i3_autostart => 0; +use i3test i3_config => < $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK') }); @@ -50,8 +47,6 @@ is(@docks, 1, 'there is still exactly one dock'); is($docks[0]->{rect}->{x}, 1024, 'dock client has moved to the other screen'); -exit_gracefully($pid); - ############################################################################### done_testing; diff --git a/testcases/t/528-workspace-next-prev-reversed.t b/testcases/t/528-workspace-next-prev-reversed.t index 00a9bbe4..b10addec 100644 --- a/testcases/t/528-workspace-next-prev-reversed.t +++ b/testcases/t/528-workspace-next-prev-reversed.t @@ -17,7 +17,12 @@ # Tests whether 'workspace next' works correctly. # use List::Util qw(first); -use i3test i3_autostart => 0; +use i3test i3_config => <root->warp_pointer(0, 0); sync_with_i3; @@ -124,6 +121,4 @@ assert_prev('2'); assert_prev('1'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/529-net-wm-desktop.t b/testcases/t/529-net-wm-desktop.t index 5f858051..63c0b6a6 100644 --- a/testcases/t/529-net-wm-desktop.t +++ b/testcases/t/529-net-wm-desktop.t @@ -16,7 +16,14 @@ # # Tests for _NET_WM_DESKTOP. # Ticket: #2153 -use i3test i3_autostart => 0; +use i3test i3_config => < 0; - -my $config = < <get_workspaces->recv; my @ws_names = map { $_->{name} } @$get_ws; +# TODO get rid of smartmatch ok(!('3' ~~ @ws_names), 'workspace 3 has been closed'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/531-fullscreen-on-given-output.t b/testcases/t/531-fullscreen-on-given-output.t index fd328653..b2040554 100644 --- a/testcases/t/531-fullscreen-on-given-output.t +++ b/testcases/t/531-fullscreen-on-given-output.t @@ -16,17 +16,13 @@ # # Tests that fullscreen windows appear on the output indicated by # their geometry -use i3test i3_autostart => 0; -use List::Util qw(first); - -my $config = < <{nodes}, $win_on_second_output->{id}); is($node1->{fullscreen_mode}, 1, "first window is fullscreen"); is($node2->{fullscreen_mode}, 1, "second window is fullscreen"); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/534-dont-warp.t b/testcases/t/534-dont-warp.t index 8f84f9ae..997340fa 100644 --- a/testcases/t/534-dont-warp.t +++ b/testcases/t/534-dont-warp.t @@ -18,13 +18,7 @@ # over an unfocused workspace. # Ticket: #2681 # Bug still in: 4.13-210-g80c23afa -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < <query_pointer_reply($cookie->{sequence}); cmp_ok($reply->{root_x}, '<', 1024, 'pointer still on fake-0'); cmp_ok($reply->{root_y}, '<', 768, 'pointer still on fake-0'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/535-workspace-next-prev.t b/testcases/t/535-workspace-next-prev.t index 1a83de23..ac80eab7 100644 --- a/testcases/t/535-workspace-next-prev.t +++ b/testcases/t/535-workspace-next-prev.t @@ -17,7 +17,12 @@ # Tests whether 'workspace next' works correctly. # use List::Util qw(first); -use i3test i3_autostart => 0; +use i3test i3_config => <root->warp_pointer(0, 0); sync_with_i3; @@ -124,6 +121,4 @@ assert_prev('2'); assert_prev('1'); -exit_gracefully($pid); - done_testing; diff --git a/testcases/t/536-net-wm-desktop_mm.t b/testcases/t/536-net-wm-desktop_mm.t index 77238946..6346ebb7 100644 --- a/testcases/t/536-net-wm-desktop_mm.t +++ b/testcases/t/536-net-wm-desktop_mm.t @@ -16,7 +16,19 @@ # # Tests for _NET_WM_DESKTOP. # Ticket: #2153 -use i3test i3_autostart => 0; +use i3test i3_config => <{value}); } -my $config = < Date: Thu, 14 Sep 2017 11:30:58 +0200 Subject: [PATCH 3/4] tests: remove the (broken) exit_gracefully check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I previously tried to fix the check, but could only come up with a fix which required removing our module pre-loading, which makes the tests considerably more expensive. Instead, let’s just remove the check. --- testcases/lib/TestWorker.pm | 9 +++------ testcases/lib/i3test.pm.in | 10 ++-------- testcases/t/000-load-deps.t | 1 - 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/testcases/lib/TestWorker.pm b/testcases/lib/TestWorker.pm index c56767c4..9716f7f1 100644 --- a/testcases/lib/TestWorker.pm +++ b/testcases/lib/TestWorker.pm @@ -47,12 +47,9 @@ sub worker { $worker->{ipc} = $ipc_child; + # Preload the i3test module: reduces user CPU from 25s to 18s require i3test; - # TODO: recycle $x - # unfortunately this fails currently with: - # Could not get reply for: xcb_intern_atom_reply at X11/XCB/Atom.pm line 22. - # $i3test::x = bless $x, 'i3test::X11'; worker_wait($worker, $outdir); exit 23; @@ -86,11 +83,11 @@ sub worker_wait { exit unless $file; - die "tried to launch nonexistend testfile $file: $!\n" + die "tried to launch nonexistent testfile $file: $!\n" unless -e $file; # start a new and self contained process: - # whatever happens in the testfile should *NOT* effect us. + # whatever happens in the testfile should *NOT* affect us. my $pid = fork // die "could not fork: $!"; if ($pid == 0) { diff --git a/testcases/lib/i3test.pm.in b/testcases/lib/i3test.pm.in index a9cfba37..222babcf 100644 --- a/testcases/lib/i3test.pm.in +++ b/testcases/lib/i3test.pm.in @@ -100,14 +100,8 @@ my $i3_pid; my $i3_autostart; END { - - # testcases which start i3 manually should always call exit_gracefully - # on their own. Let’s see, whether they really did. - if (! $i3_autostart) { - return unless $i3_pid; - - $tester->ok(undef, 'testcase called exit_gracefully()'); - } + # Skip the remaining cleanup for testcases which set i3_autostart => 0: + return if !defined($i3_pid) && !$i3_autostart; # don't trigger SIGCHLD handler local $SIG{CHLD}; diff --git a/testcases/t/000-load-deps.t b/testcases/t/000-load-deps.t index e0408338..65795305 100644 --- a/testcases/t/000-load-deps.t +++ b/testcases/t/000-load-deps.t @@ -11,7 +11,6 @@ BEGIN { IPC::Run ExtUtils::PkgConfig Inline - Test::More ); for my $dep (@deps) { use_ok($dep) or BAIL_OUT(qq|The Perl module "$dep" could not be loaded. Please see http://build.i3wm.org/docs/testsuite.html#_installing_the_dependencies|); From 24462f98aed51e936a4c86e610bddc96ba35c9af Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 14 Sep 2017 13:35:26 +0200 Subject: [PATCH 4/4] tests: unflake tests by not starting i3bar --- testcases/t/264-dock-criteria.t | 5 +++++ testcases/t/504-move-workspace-to-output.t | 5 +++++ testcases/t/526-reconfigure-dock.t | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/testcases/t/264-dock-criteria.t b/testcases/t/264-dock-criteria.t index d4b3b689..1eddba71 100644 --- a/testcases/t/264-dock-criteria.t +++ b/testcases/t/264-dock-criteria.t @@ -19,6 +19,11 @@ use i3test i3_config => < < <