tests: launch_with_config: use socket activation

This commit is contained in:
Michael Stapelberg 2011-10-04 23:33:38 +01:00
parent bf33c8d7c9
commit 8d9b4c3c04
2 changed files with 18 additions and 10 deletions

View File

@ -188,7 +188,7 @@ sub take_job {
my $output; my $output;
my $parser = TAP::Parser->new({ 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), spool => IO::Scalar->new(\$output),
merge => 1, merge => 1,
}); });

View File

@ -14,6 +14,7 @@ use Time::HiRes qw(sleep);
use Try::Tiny; use Try::Tiny;
use Cwd qw(abs_path); use Cwd qw(abs_path);
use Proc::Background; use Proc::Background;
use SocketActivation;
use v5.10; use v5.10;
@ -414,7 +415,9 @@ sub get_socket_path {
# complete-run.pl that it should not create an instance of i3 # complete-run.pl that it should not create an instance of i3
# #
sub launch_with_config { sub launch_with_config {
my ($config) = @_; my ($config, $dont_add_socket_path) = @_;
$dont_add_socket_path //= 0;
if (!defined($tmp_socket_path)) { if (!defined($tmp_socket_path)) {
$tmp_socket_path = File::Temp::tempnam('/tmp', 'i3-test-socket-'); $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); my ($fh, $tmpfile) = tempfile('i3-test-config-XXXXX', UNLINK => 1);
say $fh $config; say $fh $config;
say $fh "ipc-socket $tmp_socket_path"; say $fh "ipc-socket $tmp_socket_path" unless $dont_add_socket_path;
close($fh); close($fh);
# Use $ENV{LOGPATH}, gets set in complete-run.pl. We append instead of my $cv = AnyEvent->condvar;
# overwrite because there might be multiple instances of i3 running during my $pid = activate_i3(
# one test case. unix_socket_path => "$tmp_socket_path-activation",
my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >>$ENV{LOGPATH} 2>&1"; display => $ENV{DISPLAY},
my $process = Proc::Background->new($i3cmd); configfile => $tmpfile,
sleep 1.25; logpath => $ENV{LOGPATH},
cv => $cv,
);
# blockingly wait until i3 is ready
$cv->recv;
# force update of the cached socket path in lib/i3test # force update of the cached socket path in lib/i3test
get_socket_path(0); get_socket_path(0);
return $process; return $pid;
} }
1 1