Merge branch 'tests-i3lib-launch'

This commit is contained in:
Michael Stapelberg 2011-08-03 02:14:00 +02:00
commit 034ecbc930
7 changed files with 115 additions and 199 deletions

10
debian/changelog vendored
View File

@ -1,3 +1,13 @@
i3-wm (4.0.1-1) unstable; urgency=low
* Fix the build process of i3bar (Closes: #636274)
* Fix the build process on Mac OS X
* i3-config-wizard: also start i3bar in the keycode config template
* userguide: Remove the obsolete bar.* colors
* userguide: Use i3bar instead of dzen2 in the 'exec' example
-- Michael Stapelberg <michael@stapelberg.de> Mon, 01 Aug 2011 23:31:06 +0200
i3-wm (4.0-1) unstable; urgency=low i3-wm (4.0-1) unstable; urgency=low
* In addition to the proper flex/bison based parser for the config file * In addition to the proper flex/bison based parser for the config file

1
debian/rules vendored
View File

@ -53,6 +53,7 @@ install: build
cp man/i3-nagbar.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1 cp man/i3-nagbar.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1
cp man/i3-config-wizard.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1 cp man/i3-config-wizard.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1
cp man/i3-migrate-config-to-v4.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1 cp man/i3-migrate-config-to-v4.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1
cp i3bar/doc/i3bar.1 $(CURDIR)/debian/i3-wm/usr/share/man/man1
# Build architecture-independent files here. # Build architecture-independent files here.

View File

@ -6,15 +6,9 @@
use X11::XCB qw(:all); use X11::XCB qw(:all);
use X11::XCB::Connection; use X11::XCB::Connection;
use i3test; use i3test;
use Cwd qw(abs_path);
use Proc::Background;
use File::Temp qw(tempfile tempdir);
my $x = X11::XCB::Connection->new; my $x = X11::XCB::Connection->new;
# assuming we are run by complete-run.pl
my $i3_path = abs_path("../i3");
############################################################## ##############################################################
# 1: test the following directive: # 1: test the following directive:
# for_window [class="borderless"] border none # for_window [class="borderless"] border none
@ -23,22 +17,14 @@ my $i3_path = abs_path("../i3");
# "borderless" (should get no border) # "borderless" (should get no border)
############################################################## ##############################################################
my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-'); my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [class="borderless"] border none
for_window [title="special borderless title"] border none
EOT
my ($fh, $tmpfile) = tempfile(); my $process = launch_with_config($config);
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";
say $fh q|for_window [class="borderless"] border none|;
close($fh);
diag("Starting i3");
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
my $tmp = fresh_workspace; my $tmp = fresh_workspace;
@ -112,21 +98,14 @@ exit_gracefully($process->pid);
# only once # only once
############################################################## ##############################################################
($fh, $tmpfile) = tempfile(); $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; for_window [class="borderless"] border none
say $fh q|for_window [class="borderless"] border none|; for_window [title="special borderless title"] border none
say $fh q|for_window [title="special borderless title"] border none|; EOT
close($fh);
diag("Starting i3"); $process = launch_with_config($config);
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
$tmp = fresh_workspace; $tmp = fresh_workspace;
@ -176,22 +155,16 @@ exit_gracefully($process->pid);
# 3: match on the title, set border style *and* a mark # 3: match on the title, set border style *and* a mark
############################################################## ##############################################################
($fh, $tmpfile) = tempfile(); $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; for_window [class="borderless" title="usethis"] border none
say $fh q|for_window [class="borderless"] border none|; for_window [class="borderless"] border none
say $fh q|for_window [title="special borderless title"] border none|; for_window [title="special borderless title"] border none
say $fh q|for_window [title="special mark title"] border none, mark bleh|; for_window [title="special mark title"] border none, mark bleh
close($fh); EOT
diag("Starting i3"); $process = launch_with_config($config);
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
$tmp = fresh_workspace; $tmp = fresh_workspace;
@ -228,20 +201,13 @@ exit_gracefully($process->pid);
# 4: multiple criteria for the for_window command # 4: multiple criteria for the for_window command
############################################################## ##############################################################
($fh, $tmpfile) = tempfile(); $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; for_window [class="borderless" title="usethis"] border none
say $fh q|for_window [class="borderless" title="usethis"] border none|; EOT
close($fh);
diag("Starting i3"); $process = launch_with_config($config);
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/tmp/a 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
$tmp = fresh_workspace; $tmp = fresh_workspace;

View File

@ -5,18 +5,12 @@
# Tests if assignments work # Tests if assignments work
# #
use i3test; use i3test;
use Cwd qw(abs_path);
use Proc::Background;
use File::Temp qw(tempfile tempdir);
use X11::XCB qw(:all); use X11::XCB qw(:all);
use X11::XCB::Connection; use X11::XCB::Connection;
use v5.10; use v5.10;
my $x = X11::XCB::Connection->new; my $x = X11::XCB::Connection->new;
# assuming we are run by complete-run.pl
my $i3_path = abs_path("../i3");
# TODO: move to X11::XCB # TODO: move to X11::XCB
sub set_wm_class { sub set_wm_class {
my ($id, $class, $instance) = @_; my ($id, $class, $instance) = @_;
@ -41,23 +35,12 @@ sub set_wm_class {
# start a window and see that it does not get assigned with an empty config # start a window and see that it does not get assigned with an empty config
##################################################################### #####################################################################
my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-'); my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my ($fh, $tmpfile) = tempfile(); my $process = launch_with_config($config);
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);
diag("Starting i3");
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
my $tmp = fresh_workspace; my $tmp = fresh_workspace;
@ -88,22 +71,13 @@ sleep 0.25;
# workspace # workspace
##################################################################### #####################################################################
($fh, $tmpfile) = tempfile(); $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; assign "special" targetws
say $fh q|assign "special" → targetws|; EOT
close($fh);
diag("Starting i3"); $process = launch_with_config($config);
$i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
$process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
$tmp = fresh_workspace; $tmp = fresh_workspace;
@ -137,15 +111,7 @@ sleep 0.25;
# already, next to the existing node. # already, next to the existing node.
##################################################################### #####################################################################
diag("Starting i3"); $process = launch_with_config($config);
$i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
$process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
# initialize the target workspace, then go to a fresh one # initialize the target workspace, then go to a fresh one
ok(!("targetws" ~~ @{get_workspace_names()}), 'targetws does not exist yet'); ok(!("targetws" ~~ @{get_workspace_names()}), 'targetws does not exist yet');
@ -180,22 +146,13 @@ exit_gracefully($process->pid);
# already, next to the existing node. # already, next to the existing node.
##################################################################### #####################################################################
($fh, $tmpfile) = tempfile(); $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; assign "special" ~
say $fh q|assign "special" → ~|; EOT
close($fh);
diag("Starting i3"); $process = launch_with_config($config);
$i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
$process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
$tmp = fresh_workspace; $tmp = fresh_workspace;

View File

@ -6,39 +6,22 @@
# #
use i3test; use i3test;
use Cwd qw(abs_path);
use Proc::Background;
use File::Temp qw(tempfile tempdir);
use X11::XCB qw(:all); use X11::XCB qw(:all);
use X11::XCB::Connection; use X11::XCB::Connection;
my $x = X11::XCB::Connection->new; my $x = X11::XCB::Connection->new;
# assuming we are run by complete-run.pl
my $i3_path = abs_path("../i3");
##################################################################### #####################################################################
# 1: check that with an empty config, cons are place next to each # 1: check that with an empty config, cons are place next to each
# other and no split containers are created # other and no split containers are created
##################################################################### #####################################################################
my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-'); my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
my ($fh, $tmpfile) = tempfile(); my $process = launch_with_config($config);
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);
diag("Starting i3");
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
my $tmp = fresh_workspace; my $tmp = fresh_workspace;
@ -59,22 +42,13 @@ exit_gracefully($process->pid);
# they end up in a stacked con # they end up in a stacked con
##################################################################### #####################################################################
($fh, $tmpfile) = tempfile(); $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; workspace_layout stacked
say $fh "workspace_layout stacked"; EOT
close($fh);
diag("Starting i3"); $process = launch_with_config($config);
$i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
$process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
$tmp = fresh_workspace; $tmp = fresh_workspace;

View File

@ -5,37 +5,21 @@
# Tests if the 'force_focus_wrapping' config directive works correctly. # Tests if the 'force_focus_wrapping' config directive works correctly.
# #
use i3test; use i3test;
use Cwd qw(abs_path);
use Proc::Background;
use File::Temp qw(tempfile tempdir);
use X11::XCB qw(:all); use X11::XCB qw(:all);
use X11::XCB::Connection; use X11::XCB::Connection;
my $x = X11::XCB::Connection->new; my $x = X11::XCB::Connection->new;
# assuming we are run by complete-run.pl
my $i3_path = abs_path("../i3");
my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-');
##################################################################### #####################################################################
# 1: test the wrapping behaviour without force_focus_wrapping # 1: test the wrapping behaviour without force_focus_wrapping
##################################################################### #####################################################################
my ($fh, $tmpfile) = tempfile(); my $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; EOT
close($fh);
diag("Starting i3"); my $process = launch_with_config($config);
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
my $tmp = fresh_workspace; my $tmp = fresh_workspace;
@ -70,22 +54,13 @@ exit_gracefully($process->pid);
# 2: test the wrapping behaviour with force_focus_wrapping # 2: test the wrapping behaviour with force_focus_wrapping
##################################################################### #####################################################################
($fh, $tmpfile) = tempfile(); $config = <<EOT;
say $fh "# i3 config file (v4)"; # i3 config file (v4)
say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
say $fh "ipc-socket $socketpath"; force_focus_wrapping true
say $fh "force_focus_wrapping true"; EOT
close($fh);
diag("Starting i3"); $process = launch_with_config($config);
$i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
$process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
diag("pid = " . $process->pid);
$tmp = fresh_workspace; $tmp = fresh_workspace;

View File

@ -1,7 +1,7 @@
package i3test; package i3test;
# vim:ts=4:sw=4:expandtab # vim:ts=4:sw=4:expandtab
use File::Temp qw(tmpnam); use File::Temp qw(tmpnam tempfile tempdir);
use Test::Builder; use Test::Builder;
use X11::XCB::Rect; use X11::XCB::Rect;
use X11::XCB::Window; use X11::XCB::Window;
@ -11,13 +11,17 @@ use List::Util qw(first);
use List::MoreUtils qw(lastval); use List::MoreUtils qw(lastval);
use Time::HiRes qw(sleep); use Time::HiRes qw(sleep);
use Try::Tiny; use Try::Tiny;
use Cwd qw(abs_path);
use Proc::Background;
use v5.10; use v5.10;
use Exporter (); use Exporter ();
our @EXPORT = qw(get_workspace_names get_unused_workspace fresh_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window get_dock_clients cmd does_i3_live exit_gracefully workspace_exists focused_ws get_socket_path); our @EXPORT = qw(get_workspace_names get_unused_workspace fresh_workspace get_ws_content get_ws get_focused open_empty_con open_standard_window get_dock_clients cmd does_i3_live exit_gracefully workspace_exists focused_ws get_socket_path launch_with_config);
my $tester = Test::Builder->new(); my $tester = Test::Builder->new();
my $_cached_socket_path = undef; my $_cached_socket_path = undef;
my $tmp_socket_path = undef;
BEGIN { BEGIN {
my $window_count = 0; my $window_count = 0;
@ -229,4 +233,33 @@ sub get_socket_path {
return $socketpath; return $socketpath;
} }
#
# launches a new i3 process with the given string as configuration file.
# useful for tests which test specific config file directives.
#
# be sure to use !NO_I3_INSTANCE! somewhere in the file to signal
# complete-run.pl that it should not create an instance of i3
#
sub launch_with_config {
my ($config) = @_;
if (!defined($tmp_socket_path)) {
$tmp_socket_path = File::Temp::tempnam('/tmp', 'i3-test-socket-');
}
my ($fh, $tmpfile) = tempfile('i3-test-config-XXXXX', UNLINK => 1);
say $fh $config;
say $fh "ipc-socket $tmp_socket_path";
close($fh);
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
my $process = Proc::Background->new($i3cmd);
sleep 1;
# force update of the cached socket path in lib/i3test
get_socket_path(0);
return $process;
}
1 1