From 8d9b4c3c04365ffb53fe43a28022651e64dc103b Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 4 Oct 2011 23:33:38 +0100 Subject: [PATCH] tests: launch_with_config: use socket activation --- testcases/complete-run.pl | 2 +- testcases/t/lib/i3test.pm | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/testcases/complete-run.pl b/testcases/complete-run.pl index d427d70a..322c23f2 100755 --- a/testcases/complete-run.pl +++ b/testcases/complete-run.pl @@ -188,7 +188,7 @@ sub take_job { my $output; my $parser = TAP::Parser->new({ - exec => [ 'sh', '-c', qq|DISPLAY=$display LOGPATH="$logpath" /usr/bin/perl -It/lib $test| ], + exec => [ 'sh', '-c', qq|DISPLAY=$display LOGPATH="$logpath" /usr/bin/perl -It/lib -Ilib $test| ], spool => IO::Scalar->new(\$output), merge => 1, }); diff --git a/testcases/t/lib/i3test.pm b/testcases/t/lib/i3test.pm index c890693c..14ec8d32 100644 --- a/testcases/t/lib/i3test.pm +++ b/testcases/t/lib/i3test.pm @@ -14,6 +14,7 @@ use Time::HiRes qw(sleep); use Try::Tiny; use Cwd qw(abs_path); use Proc::Background; +use SocketActivation; use v5.10; @@ -414,7 +415,9 @@ sub get_socket_path { # complete-run.pl that it should not create an instance of i3 # sub launch_with_config { - my ($config) = @_; + my ($config, $dont_add_socket_path) = @_; + + $dont_add_socket_path //= 0; if (!defined($tmp_socket_path)) { $tmp_socket_path = File::Temp::tempnam('/tmp', 'i3-test-socket-'); @@ -422,20 +425,25 @@ sub launch_with_config { my ($fh, $tmpfile) = tempfile('i3-test-config-XXXXX', UNLINK => 1); say $fh $config; - say $fh "ipc-socket $tmp_socket_path"; + say $fh "ipc-socket $tmp_socket_path" unless $dont_add_socket_path; close($fh); - # Use $ENV{LOGPATH}, gets set in complete-run.pl. We append instead of - # overwrite because there might be multiple instances of i3 running during - # one test case. - my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >>$ENV{LOGPATH} 2>&1"; - my $process = Proc::Background->new($i3cmd); - sleep 1.25; + my $cv = AnyEvent->condvar; + my $pid = activate_i3( + unix_socket_path => "$tmp_socket_path-activation", + display => $ENV{DISPLAY}, + configfile => $tmpfile, + logpath => $ENV{LOGPATH}, + cv => $cv, + ); + + # blockingly wait until i3 is ready + $cv->recv; # force update of the cached socket path in lib/i3test get_socket_path(0); - return $process; + return $pid; } 1 -- 2.39.5