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