From 26c1a463db8ae91cf1a405b0345074ca3e718c97 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 27 Jul 2011 14:34:35 +0200 Subject: [PATCH] tests: keep an X11 connection open to every display, fixes races Otherwise, i3 is the only client and thus the X server shuts down after i3 disconnects. Xdummy restarts an X server, but that takes some time and therefore sometimes the next testcase was unable to connect. --- testcases/complete-run.pl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/testcases/complete-run.pl b/testcases/complete-run.pl index 083e1ebb..c05d6e5b 100755 --- a/testcases/complete-run.pl +++ b/testcases/complete-run.pl @@ -28,6 +28,7 @@ use AnyEvent::I3 qw(:all); use Try::Tiny; use Getopt::Long; use Time::HiRes qw(sleep); +use X11::XCB::Connection; # install a dummy CHLD handler to overwrite the CHLD handler of AnyEvent / EV # XXX: we could maybe also use a different loop than the default loop in EV? @@ -54,6 +55,23 @@ my $result = GetOptions( @displays = qw(:1) if @displays == 0; +# connect to all displays for two reasons: +# 1: check if the display actually works +# 2: keep the connection open so that i3 is not the only client. this prevents +# the X server from exiting (Xdummy will restart it, but not quick enough +# sometimes) +my @conns; +my @wdisplays; +for my $display (@displays) { + try { + my $x = X11::XCB::Connection->new(display => $display); + push @conns, $x; + push @wdisplays, $display; + } catch { + say STDERR "WARNING: Not using X11 display $display, could not connect"; + }; +} + my $i3cmd = abs_path("../i3") . " -V -d all --disable-signalhandler"; my $config = slurp('i3-test.config'); @@ -84,7 +102,7 @@ my $cv = AnyEvent->condvar; # We start tests concurrently: For each display, one test gets started. Every # test starts another test after completing. -take_job($_) for @displays; +take_job($_) for @wdisplays; # # Takes a test from the beginning of @testfiles and runs it.