Skip to content

Commit

Permalink
Merge branch 'next' into initial-zombie-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kolayne committed May 7, 2024
2 parents 0d449fb + 6094944 commit 1a3b1d3
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 166 deletions.
9 changes: 9 additions & 0 deletions AnyEvent-I3/Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Revision history for AnyEvent-I3

0.19 2024-04-09

* use Carp for errors (includes stacktraces)
* introduce (preferred) RUN_COMMAND spelling
* migrate tooling to ExtUtils::MakeMaker
* implement the tick event
* introduce the sync IPC command
* introduce the GET_BINDING_STATE IPC command

0.18 2017-08-19

* support the GET_CONFIG command
Expand Down
51 changes: 15 additions & 36 deletions AnyEvent-I3/lib/AnyEvent/I3.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use AnyEvent::Handle;
use AnyEvent::Socket;
use AnyEvent;
use Encode;
use Scalar::Util qw(tainted);
use Carp;

=head1 NAME
Expand All @@ -17,11 +16,11 @@ AnyEvent::I3 - communicate with the i3 window manager
=cut

our $VERSION = '0.18';
our $VERSION = '0.19';

=head1 VERSION
Version 0.18
Version 0.19
=head1 SYNOPSIS
Expand Down Expand Up @@ -132,35 +131,10 @@ sub i3 {
AnyEvent::I3->new(@_)
}

# Calls i3, even when running in taint mode.
sub _call_i3 {
my ($args) = @_;

my $path_tainted = tainted($ENV{PATH});
# This effectively circumvents taint mode checking for $ENV{PATH}. We
# do this because users might specify PATH explicitly to call i3 in a
# custom location (think ~/.bin/).
(local $ENV{PATH}) = ($ENV{PATH} =~ /(.*)/);

# In taint mode, we also need to remove all relative directories from
# PATH (like . or ../bin). We only do this in taint mode and warn the
# user, since this might break a real-world use case for some people.
if ($path_tainted) {
my @dirs = split /:/, $ENV{PATH};
my @filtered = grep !/^\./, @dirs;
if (scalar @dirs != scalar @filtered) {
$ENV{PATH} = join ':', @filtered;
warn qq|Removed relative directories from PATH because you | .
qq|are running Perl with taint mode enabled. Remove -T | .
qq|to be able to use relative directories in PATH. | .
qq|New PATH is "$ENV{PATH}"|;
}
}
# Otherwise the qx() operator wont work:
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
chomp(my $result = qx(i3 $args));
# Circumventing taint mode again: the socket can be anywhere on the
# system and that’s okay.
if ($result =~ /^([^\0]+)$/) {
return $1;
}
Expand All @@ -182,21 +156,21 @@ instance on the current DISPLAY which is almost always what you want.
sub new {
my ($class, $path) = @_;

$path = _call_i3('--get-socketpath') unless $path;

# This is the old default path (v3.*). This fallback line can be removed in
# a year from now. -- Michael, 2012-07-09
$path ||= '~/.i3/ipc.sock';
# We have I3SOCK now
$path ||= $ENV{I3SOCK};
$path ||= _call_i3('--get-socketpath');

# Check if we need to resolve ~
if ($path =~ /~/) {
# We use getpwuid() instead of $ENV{HOME} because the latter is tainted
# and thus produces warnings when running tests with perl -T
my $home = (getpwuid($<))[7];
my $home = $ENV{HOME};
confess "Could not get home directory" unless $home and -d $home;
$path =~ s/~/$home/g;
}

if(!-S $path) {
die "$path is not a socket", $/;
}

bless { path => $path } => $class;
}

Expand Down Expand Up @@ -315,6 +289,11 @@ sub subscribe {

# Register callbacks for each message type
for my $key (keys %{$callbacks}) {
if (!exists $events{$key}) {
warn "Could not subscribe to event type '$key'." .
" Supported events are " . join(" ", sort keys %events), $/;
next;
}
my $type = $events{$key};
$self->{callbacks}->{$type} = $callbacks->{$key};
}
Expand Down
2 changes: 1 addition & 1 deletion AnyEvent-I3/t/00-load.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!perl -T
#!perl

use Test::More tests => 1;

Expand Down
2 changes: 1 addition & 1 deletion AnyEvent-I3/t/01-workspaces.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!perl -T
#!perl
# vim:ts=4:sw=4:expandtab

use Test::More tests => 3;
Expand Down
2 changes: 1 addition & 1 deletion AnyEvent-I3/t/02-sugar.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!perl -T
#!perl
# vim:ts=4:sw=4:expandtab

use Test::More tests => 3;
Expand Down
2 changes: 1 addition & 1 deletion AnyEvent-I3/t/boilerplate.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!perl -T
#!perl

use strict;
use warnings;
Expand Down
2 changes: 1 addition & 1 deletion AnyEvent-I3/t/manifest.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!perl -T
#!perl

use strict;
use warnings;
Expand Down
2 changes: 1 addition & 1 deletion AnyEvent-I3/t/pod.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!perl -T
#!perl

use strict;
use warnings;
Expand Down
10 changes: 5 additions & 5 deletions docs/i3bar-workspace-protocol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ i3-msg -t subscribe -m '["workspace", "output"]' | {
# avoids having an empty bar when starting up.
i3-msg -t get_workspaces;
# Then, while we receive events, update the workspace information.
while read; do i3-msg -t get_workspaces; done;
while read EVENT; do i3-msg -t get_workspaces; done;
}
------------------------------

Expand All @@ -139,7 +139,7 @@ i3-msg -t subscribe -m '["workspace", "output"]' | {
#!/bin/sh
i3-msg -t subscribe -m '["workspace", "output"]' | {
i3-msg -t get_workspaces;
while read; do i3-msg -t get_workspaces; done;
while read EVENT; do i3-msg -t get_workspaces; done;
} | jq --unbuffered -c '[ .[] | select(.name != "foo" or .focused) ]'
------------------------------

Expand All @@ -153,7 +153,7 @@ might mean that you are getting an empty bar until enough events are written.
#!/bin/sh
i3-msg -t subscribe -m '["workspace", "output"]' | {
i3-msg -t get_workspaces;
while read; do i3-msg -t get_workspaces; done;
while read EVENT; do i3-msg -t get_workspaces; done;
} | jq --unbuffered -c '
def fake_ws(name): {
name: name,
Expand All @@ -169,7 +169,7 @@ i3-msg -t subscribe -m '["workspace", "output"]' | {
#!/bin/sh
i3-msg -t subscribe -m '["workspace", "output"]' | {
i3-msg -t get_workspaces;
while read; do i3-msg -t get_workspaces; done;
while read EVENT; do i3-msg -t get_workspaces; done;
} | jq --unbuffered -c 'sort_by(.name) | reverse'
------------------------------

Expand All @@ -179,6 +179,6 @@ i3-msg -t subscribe -m '["workspace", "output"]' | {
#!/bin/sh
i3-msg -t subscribe -m '["workspace", "output"]' | {
i3-msg -t get_workspaces;
while read; do i3-msg -t get_workspaces; done;
while read EVENT; do i3-msg -t get_workspaces; done;
} | jq --unbuffered -c '[ .[] | .name |= . + " foo" ]'
------------------------------
140 changes: 68 additions & 72 deletions docs/testsuite
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,20 @@ used to install the testsuite. Many users prefer to use the more modern
The tests additionally require +Xephyr(1)+ to run a nested X server. Install
+xserver-xephyr+ on Debian or +xorg-server-xephyr+ on Arch Linux.

.Installing testsuite dependencies using cpanminus (preferred)
.Installing testsuite dependencies using cpanminus
--------------------------------------------------------------------------------
$ cd ~/i3/testcases
$ sudo apt-get install cpanminus
$ sudo cpanm .
# Install testsuite system-level dependencies. Xvfb is optional but recommended.
$ sudo apt-get install xcb-proto cpanminus xvfb xserver-xephyr
# Install dependencies in ~/perl5 local library
$ cpanm --local-lib=~/perl5 local::lib App::cpanminus Module::Install
# Activate the local library
$ eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
$ cd ~/i3/testcases/
$ cpanm .
$ cd ~/i3/AnyEvent-I3
$ sudo cpanm Module::Install
$ sudo cpanm .
$ cpanm .
--------------------------------------------------------------------------------

If you don’t want to use cpanminus for some reason, the same works with cpan:

.Installing testsuite dependencies using cpan
--------------------------------------------------------------------------------
$ cd ~/i3/testcases
$ sudo cpan .
$ cd ~/i3/AnyEvent-I3
$ sudo cpan Module::Install
$ sudo cpan .
--------------------------------------------------------------------------------

In case you don’t have root permissions, you can also install into your home
directory, see https://michael.stapelberg.de/cpan/

=== Mechanisms

==== Script: complete-run
Expand All @@ -119,48 +109,57 @@ tests are run under Xvfb.
---------------------------------------
$ cd ~/i3

$ mkdir -p build && cd build
$ mkdir -p build

$ meson ..
$ meson setup build
$ cd build

$ ninja
$ meson compile
# output omitted because it is very long

$ cd testcases

$ ./complete-run.pl
# output omitted because it is very long
All tests successful.
Files=78, Tests=734, 27 wallclock secs ( 0.38 usr 0.48 sys + 17.65 cusr 3.21 csys = 21.72 CPU)
Result: PASS

$ ./complete-run.pl t/04-floating.t
[:3] i3 startup: took 0.07s, status = 1
[:3] Running t/04-floating.t with logfile testsuite-2011-09-24-16-06-04-4.0.2-226-g1eb011a/i3-log-for-04-floating.t
[:3] t/04-floating.t finished
[:3] killing i3
output for t/04-floating.t:
ok 1 - use X11::XCB::Window;
ok 2 - The object isa X11::XCB::Window
ok 3 - Window is mapped
ok 4 - i3 raised the width to 75
ok 5 - i3 raised the height to 50
ok 6 - i3 did not map it to (0x0)
ok 7 - The object isa X11::XCB::Window
ok 8 - i3 let the width at 80
ok 9 - i3 let the height at 90
ok 10 - i3 mapped it to x=1
ok 11 - i3 mapped it to y=18
ok 12 - The object isa X11::XCB::Window
ok 13 - i3 let the width at 80
ok 14 - i3 let the height at 90
1..14
$ ./complete-run.pl t/005-floating.t
Running tests under Xvfb display :99
Starting 1 Xephyr instances, starting at :100...

Rough time estimate for this run: 9.65 seconds

Writing logfile to 'testsuite-2024-05-01-21-33-45-4.23-28-g5834b7e8/complete-run.log'...
[:100] i3/testcases/t/005-floating.t: finished
completed 0 of 1 tests

All tests successful.
Files=1, Tests=14, 0 wallclock secs ( 0.01 usr 0.00 sys + 0.19 cusr 0.03 csys = 0.23 CPU)
Files=1, Tests=13, 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)
Result: PASS

$ less latest/i3-log-for-04-floating.t
The slowest tests are:
i3/testcases/t/005-floating.t with 0.07 seconds

Test output:
[:100] i3/testcases/t/005-floating.t: starting
[:100] i3/testcases/t/005-floating.t: finished
output for i3/testcases/t/005-floating.t:
ok 1 - An object of class 'X11::XCB::Window' isa 'X11::XCB::Window'
ok 2 - Window is mapped
ok 3 - i3 raised the width to 75
ok 4 - i3 raised the height to 50
ok 5 - i3 did not map it to (0x0)
ok 6 - An object of class 'X11::XCB::Window' isa 'X11::XCB::Window'
ok 7 - i3 let the width at 80
ok 8 - i3 let the height at 90
ok 9 - i3 mapped it to x=20
ok 10 - i3 mapped it to y=20
ok 11 - An object of class 'X11::XCB::Window' isa 'X11::XCB::Window'
ok 12 - i3 let the width at 80
ok 13 - i3 let the height at 90
1..13

$ less latest/i3-log-for-005-floating.t
----------------------------------------

If your attempt to run the tests with a bare call to ./complete-run.pl fails, try this:
Expand All @@ -172,37 +171,34 @@ $ ./complete-run.pl --parallel=1 --keep-xserver-output
This will show the output of Xephyr, which is the X server implementation we
use for testing.

===== make command: +make check+
Make check runs the i3 testsuite.
You can still use ./testcases/complete-run.pl to get the interactive progress output.
===== ninja command: +ninja test+
+ninja test+ runs the i3 testsuite.
You can still use ./complete-run.pl to get the interactive progress output.

.Example invocation of +make check+
.Example invocation of +ninja test+
---------------------------------------
$ cd ~/i3

$ mkdir -p build && cd build
$ mkdir -p build

$ meson ..
$ meson setup build
$ cd build

$ ninja
# output omitted because it is very long
$ ninja test
[1/102] Generating config.h with a custom command
[1/2] Running all tests.
1/1 complete-run OK 34.39s

$ make check
# output omitted because it is very long
PASS: testcases/complete-run.pl
============================================================================
Testsuite summary for i3 4.13
============================================================================
# TOTAL: 1
# PASS: 1
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================

$ less test-suite.log
Ok: 1
Expected Fail: 0
Fail: 0
Unexpected Pass: 0
Skipped: 0
Timeout: 0

Full log written to i3/build/meson-logs/testlog.txt

$ less latest/complete-run.log
----------------------------------------

==== Coverage testing
Expand Down
2 changes: 1 addition & 1 deletion i3-input/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ int main(int argc, char *argv[]) {
socket_path = sstrdup(optarg);
break;
case 'v':
printf("i3-input " I3_VERSION);
printf("i3-input " I3_VERSION "\n");
return EXIT_OK;
case 'p':
/* This option is deprecated, but will still work in i3 v4.1, 4.2 and 4.3 */
Expand Down
1 change: 1 addition & 0 deletions release-notes/bugfixes/99-errorlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix error log related crash
1 change: 1 addition & 0 deletions release-notes/changes/9-multiple-_NET_WM_STATE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
support multiple _NET_WM_STATE changes in one ClientMessage

0 comments on commit 1a3b1d3

Please sign in to comment.