tests: Convert all testcases to use the new launch_with_config API

It now returns a pid directly, not a Proc::Background object.
This commit is contained in:
Michael Stapelberg 2011-10-04 23:34:23 +01:00
parent 8d9b4c3c04
commit 4e1d50fa3a
8 changed files with 83 additions and 85 deletions

View File

@ -18,26 +18,21 @@ my $i3_path = abs_path("../i3");
# default case: socket will be created in /tmp/i3-<username>/ipc-socket.<pid>
#####################################################################
my ($fh, $tmpfile) = tempfile('/tmp/i3-test-config.XXXXXX', UNLINK => 1);
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
close($fh);
my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
diag("Starting i3");
my $i3cmd = "unset XDG_RUNTIME_DIR; exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
diag("pid = " . $process->pid);
# ensure XDG_RUNTIME_DIR is not set
delete $ENV{XDG_RUNTIME_DIR};
my $pid = launch_with_config($config, 1);
my $folder = "/tmp/i3-" . getpwuid(getuid());
ok(-d $folder, "folder $folder exists");
my $socketpath = "$folder/ipc-socket." . $process->pid;
my $socketpath = "$folder/ipc-socket." . $pid;
ok(-S $socketpath, "file $socketpath exists and is a socket");
exit_gracefully($process->pid, $socketpath);
sleep 0.25;
exit_gracefully($pid);
#####################################################################
# XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
@ -47,17 +42,15 @@ my $rtdir = tempdir(CLEANUP => 1);
ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
$i3cmd = "export XDG_RUNTIME_DIR=$rtdir; exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
$process = Proc::Background->new($i3cmd);
sleep 1;
$ENV{XDG_RUNTIME_DIR} = $rtdir;
$pid = launch_with_config($config, 1);
ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
$socketpath = "$rtdir/i3/ipc-socket." . $process->pid;
$socketpath = "$rtdir/i3/ipc-socket." . $pid;
ok(-S $socketpath, "file $socketpath exists and is a socket");
exit_gracefully($process->pid, $socketpath);
sleep 0.25;
exit_gracefully($pid);
#####################################################################
# configuration file case: socket gets placed whereever we specify
@ -67,18 +60,16 @@ my $tmpdir = tempdir(CLEANUP => 1);
$socketpath = $tmpdir . "/config.sock";
ok(! -e $socketpath, "$socketpath does not exist yet");
($fh, $tmpfile) = tempfile('/tmp/i3-test-config.XXXXXX', UNLINK => 1);
say $fh "# i3 config file (v4)";
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
say $fh "ipc-socket $socketpath";
close($fh);
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
ipc-socket $socketpath
EOT
$i3cmd = "export XDG_RUNTIME_DIR=$rtdir; exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
$process = Proc::Background->new($i3cmd);
sleep 1;
$pid = launch_with_config($config, 1);
ok(-S $socketpath, "file $socketpath exists and is a socket");
exit_gracefully($process->pid, $socketpath);
exit_gracefully($pid);
done_testing;

View File

@ -24,7 +24,7 @@ for_window [class="borderless"] border none
for_window [title="special borderless title"] border none
EOT
my $process = launch_with_config($config);
my $pid = launch_with_config($config);
my $tmp = fresh_workspace;
@ -93,7 +93,7 @@ wait_for_unmap $x;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 2: match on the title, check if for_window is really executed
@ -107,7 +107,7 @@ for_window [class="borderless"] border none
for_window [title="special borderless title"] border none
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -152,7 +152,7 @@ wait_for_unmap $x;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no more nodes');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 3: match on the title, set border style *and* a mark
@ -167,7 +167,7 @@ for_window [title="special borderless title"] border none
for_window [title="special mark title"] border none, mark bleh
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -199,7 +199,7 @@ cmd qq|[con_mark="bleh"] focus|;
@content = @{get_ws_content($tmp)};
ok($content[0]->{focused}, 'first node focused');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 4: multiple criteria for the for_window command
@ -211,7 +211,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [class="borderless" title="usethis"] border none
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -233,12 +233,15 @@ wait_for_map $x;
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border');
$window->unmap;
cmd 'kill';
wait_for_unmap $x;
$window->destroy;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 0, 'no nodes on this workspace now');
$window->_create;
set_wm_class($window->id, 'borderless', 'borderless');
$window->name('notthis');
$window->map;
@ -249,7 +252,7 @@ cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'no border');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 5: check that a class criterion does not match the instance
@ -261,7 +264,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [class="foo"] border 1pixel
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -283,7 +286,7 @@ wait_for_map $x;
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'normal border, not matched');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 6: check that the 'instance' criterion works
@ -296,7 +299,7 @@ for_window [class="foo"] border 1pixel
for_window [instance="foo"] border none
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -318,7 +321,7 @@ wait_for_map $x;
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 7: check that invalid criteria dont end up matching all windows
@ -333,7 +336,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [id="asdf"] border none
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -355,7 +358,7 @@ wait_for_map $x;
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'normal', 'normal border');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 8: check that the role criterion works properly
@ -370,7 +373,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [window_role="i3test"] border none
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -403,7 +406,7 @@ wait_for_map $x;
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border (window_role)');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 9: another test for the window_role, but this time it changes
@ -419,7 +422,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [window_role="i3test"] border none
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -460,7 +463,7 @@ sync_with_i3 $x;
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border (window_role 2)');
exit_gracefully($process->pid);
exit_gracefully($pid);
done_testing;

View File

@ -40,7 +40,7 @@ my $config = <<EOT;
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my $process = launch_with_config($config);
my $pid = launch_with_config($config);
my $tmp = fresh_workspace;
@ -61,7 +61,7 @@ wait_for_map $x;
ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace');
exit_gracefully($process->pid);
exit_gracefully($pid);
$window->destroy;
@ -76,7 +76,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
assign "special" targetws
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -102,7 +102,7 @@ ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists');
$window->destroy;
exit_gracefully($process->pid);
exit_gracefully($pid);
sleep 0.25;
@ -111,7 +111,7 @@ sleep 0.25;
# already, next to the existing node.
#####################################################################
$process = launch_with_config($config);
$pid = launch_with_config($config);
# initialize the target workspace, then go to a fresh one
ok(!("targetws" ~~ @{get_workspace_names()}), 'targetws does not exist yet');
@ -144,7 +144,7 @@ sync_with_i3 $x;
ok(@{get_ws_content($tmp)} == 0, 'still no containers');
ok(@{get_ws_content('targetws')} == 2, 'two containers on targetws');
exit_gracefully($process->pid);
exit_gracefully($pid);
#####################################################################
# start a window and see that it gets assigned to a workspace which has content
@ -157,7 +157,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
assign "special" ~
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -184,7 +184,7 @@ ok(@{$content->{floating_nodes}} == 1, 'one floating con');
$window->destroy;
exit_gracefully($process->pid);
exit_gracefully($pid);
sleep 0.25;
@ -198,7 +198,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
assign "special" ~
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -225,7 +225,7 @@ ok(@{$content->{floating_nodes}} == 1, 'one floating con');
$window->destroy;
exit_gracefully($process->pid);
exit_gracefully($pid);
sleep 0.25;
@ -241,7 +241,11 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
assign "special" ~
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
# TODO: replace this with checking the process hierarchy
# XXX: give i3-nagbar some time to start up
sleep 1;
$tmp = fresh_workspace;
@ -275,7 +279,7 @@ $window->destroy;
does_i3_live;
exit_gracefully($process->pid);
exit_gracefully($pid);
sleep 0.25;

View File

@ -21,7 +21,7 @@ my $config = <<EOT;
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my $process = launch_with_config($config);
my $pid = launch_with_config($config);
my $tmp = fresh_workspace;
@ -37,7 +37,7 @@ ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
isnt($content[0]->{layout}, 'stacked', 'layout not stacked');
isnt($content[1]->{layout}, 'stacked', 'layout not stacked');
exit_gracefully($process->pid);
exit_gracefully($pid);
#####################################################################
# 2: set workspace_layout stacked, check that when opening two cons,
@ -50,7 +50,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
workspace_layout stacked
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -122,6 +122,6 @@ is($content[1]->{layout}, 'stacked', 'layout stacked');
is(@content, 1, 'one con on target workspace');
is($content[0]->{layout}, 'stacked', 'layout stacked');
exit_gracefully($process->pid);
exit_gracefully($pid);
done_testing;

View File

@ -19,7 +19,7 @@ my $config = <<EOT;
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my $process = launch_with_config($config);
my $pid = launch_with_config($config);
my $tmp = fresh_workspace;
@ -48,7 +48,7 @@ is($x->input_focus, $second->id, 'second window focused');
cmd 'focus right';
is($x->input_focus, $third->id, 'third window focused');
exit_gracefully($process->pid);
exit_gracefully($pid);
#####################################################################
# 2: test the wrapping behaviour with force_focus_wrapping
@ -60,7 +60,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
force_focus_wrapping true
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -92,6 +92,6 @@ is($x->input_focus, $second->id, 'second window focused');
cmd 'focus right';
is($x->input_focus, $first->id, 'first window focused');
exit_gracefully($process->pid);
exit_gracefully($pid);
done_testing;

View File

@ -19,12 +19,12 @@ my $config = <<EOT;
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my $process = launch_with_config($config);
my $pid = launch_with_config($config);
my @names = @{get_workspace_names()};
cmp_deeply(\@names, [ '1' ], 'i3 starts on workspace 1 without any configuration');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 2: with named workspaces, i3 should start on the first named one
@ -37,12 +37,12 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
bindsym Mod1+1 workspace foobar
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
my @names = @{get_workspace_names()};
cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar');
exit_gracefully($process->pid);
exit_gracefully($pid);
##############################################################
# 3: the same test as 2, but with a quoted workspace name
@ -55,11 +55,11 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
bindsym Mod1+1 workspace "foobar"
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
my @names = @{get_workspace_names()};
cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar');
exit_gracefully($process->pid);
exit_gracefully($pid);
done_testing;

View File

@ -42,7 +42,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
assign "special" targetws
EOT
my $process = launch_with_config($config);
my $pid = launch_with_config($config);
my $tmp = fresh_workspace;
@ -88,7 +88,7 @@ ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace');
ok(@{get_ws_content('targetws')} == 1, 'special window on targetws');
ok(get_ws($tmp)->{focused}, 'current workspace still focused');
exit_gracefully($process->pid);
exit_gracefully($pid);
$window->destroy;

View File

@ -19,7 +19,7 @@ my $config = <<EOT;
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my $process = launch_with_config($config);
my $pid = launch_with_config($config);
my $tmp = fresh_workspace;
@ -31,7 +31,7 @@ my @content = @{get_ws_content($tmp)};
ok(@content == 1, 'one container opened');
is($content[0]->{border}, 'normal', 'border normal by default');
exit_gracefully($process->pid);
exit_gracefully($pid);
#####################################################################
# 2: check that new tiling windows start with '1pixel' border when
@ -45,7 +45,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
new_window 1pixel
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -57,7 +57,7 @@ $first = open_window($x);
ok(@content == 1, 'one container opened');
is($content[0]->{border}, '1pixel', 'border normal by default');
exit_gracefully($process->pid);
exit_gracefully($pid);
#####################################################################
# 3: check that new floating windows start with 'normal' border unless
@ -69,7 +69,7 @@ $config = <<EOT;
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -83,7 +83,7 @@ ok(@floating == 1, 'one floating container opened');
my $floatingcon = $floating[0];
is($floatingcon->{nodes}->[0]->{border}, 'normal', 'border normal by default');
exit_gracefully($process->pid);
exit_gracefully($pid);
#####################################################################
# 4: check that new floating windows start with '1pixel' border when
@ -97,7 +97,7 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
new_float 1pixel
EOT
$process = launch_with_config($config);
$pid = launch_with_config($config);
$tmp = fresh_workspace;
@ -111,6 +111,6 @@ ok(@floating == 1, 'one floating container opened');
$floatingcon = $floating[0];
is($floatingcon->{nodes}->[0]->{border}, '1pixel', 'border normal by default');
exit_gracefully($process->pid);
exit_gracefully($pid);
done_testing;