Skip Menu |

This queue is for tickets about the X11-GUITest CPAN distribution.

Report information
The Basics
Id: 93667
Status: resolved
Priority: 0/
Queue: X11-GUITest

People
Owner: Nobody in particular
Requestors: DDICK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.27
Fixed in: (no value)



Subject: PATCH: provide a xeyes window to allow "make test" in an xvfb-run test environment
I am building the X11::GUITest package for Fedora 20 and EPEL6 (RHEL6) and the following patch allows the full test suite to run in a headless environment.
Subject: xvfb_run_x11_guitest.patch
diff -Naur old/t/test.t new/t/test.t --- t/test.t 2011-05-15 12:03:11.000000000 +1000 +++ t/test.t 2014-03-09 17:17:42.388697492 +1100 @@ -23,8 +23,36 @@ # All seems ok, so plan on running the tests. print "1..23\n"; } +my $xvfb_xeyes_pid; # In an xvfb-run environment, there is usually no windows at all, if there is no window, attempt to create one and then kill it at the end of the test. +unless (FindWindowLike(".*")) { + foreach my $path ('/usr/bin/xeyes') { + if (-x $path) { + if ($xvfb_xeyes_pid = fork) { + WAIT: foreach my $count ( 1 .. 20 ) { + if (FindWindowLike(".*")) { + last WAIT; + } + if (!kill 0, $xvfb_xeyes_pid) { + last WAIT; + } + sleep 1; + } + } elsif (defined $xvfb_xeyes_pid) { + eval { + exec({ $path } $path); + } or do { + warn $@; + }; + exit 1; + } + } + } +} END { print "not ok 1\n" unless $loaded; + if (defined $xvfb_xeyes_pid) { + kill 15, $xvfb_xeyes_pid; + } } use X11::GUITest qw/ :ALL
improvements on previous patch to include a waitpid for programs that exit immediately. This seems incredibly unlikely, but this patch now handles the following; * /usr/bin/xeyes not present * /usr/bin/xeyes that hangs forever with or without showing a window * /usr/bin/xeyes that terminates immediately with or without showing a window all these cases will probably result in the test failing of course, but it should prevent a "hang" of the "make test" step In addition, there is an easy mechanism for adding other paths for other distros to test (adding new paths to the XAPP list)
Subject: xvfb_run_x11_guitest.patch
diff -Naur old/t/test.t new/t/test.t --- t/test.t 2011-05-15 12:03:11.000000000 +1000 +++ t/test.t 2014-03-10 11:07:38.306204972 +1100 @@ -23,8 +23,47 @@ # All seems ok, so plan on running the tests. print "1..23\n"; } +use POSIX(); +my $xvfb_xeyes_pid; # In an xvfb-run environment, there is usually no windows at all, if there is no window, attempt to create one and then kill it at the end of the test. +unless (FindWindowLike(".*")) { + XAPP: foreach my $path ('/usr/bin/xeyes') { + if (-x $path) { + my $found_window; + if ($xvfb_xeyes_pid = fork) { + WAIT: foreach my $count ( 1 .. 60 ) { + if (FindWindowLike(".*")) { + $found_window = 1; + last WAIT; + } + if (waitpid $xvfb_xeyes_pid, POSIX::WNOHANG()) { + $xvfb_xeyes_pid = undef; + last WAIT; + } + if (!kill 0, $xvfb_xeyes_pid) { + $xvfb_xeyes_pid = undef; + last WAIT; + } + sleep 1; + } + } elsif (defined $xvfb_xeyes_pid) { + eval { + exec({ $path } $path); + } or do { + warn $@; + }; + exit 1; + } + if ($found_window) { + last XAPP; + } + } + } +} END { print "not ok 1\n" unless $loaded; + if (defined $xvfb_xeyes_pid) { + kill 15, $xvfb_xeyes_pid; + } } use X11::GUITest qw/ :ALL