]> git.sur5r.net Git - i3/i3/blobdiff - testcases/lib/TestWorker.pm
Merge branch 'master' into next
[i3/i3] / testcases / lib / TestWorker.pm
index 855396263994c7fa4767bc03890366cc7ecf0949..140537d4c74d54a46c61d576df76ee01fe642eb8 100644 (file)
@@ -8,18 +8,24 @@ use IO::Handle; # for ->autoflush
 
 use POSIX ();
 
+use Errno qw(EAGAIN);
+
 use Exporter 'import';
 our @EXPORT = qw(worker worker_next);
 
 use File::Basename qw(basename);
 my @x;
+my $options;
 
 sub worker {
-    my ($display, $x, $outdir) = @_;
+    my ($display, $x, $outdir, $optref) = @_;
 
     # make sure $x hangs around
     push @x, $x;
 
+    # store the options hashref
+    $options = $optref;
+
     socketpair(my $ipc_child, my $ipc, AF_UNIX, SOCK_DGRAM, PF_UNSPEC)
         or die "socketpair: $!";
 
@@ -70,7 +76,12 @@ sub worker_wait {
     my $ipc = $self->{ipc};
     my $ipc_fd = fileno($ipc);
 
-    while (defined(my $file = $ipc->getline)) {
+    while (1) {
+        my $file = $ipc->getline;
+        if (!defined($file)) {
+            next if $! == EAGAIN;
+            last;
+        }
         chomp $file;
 
         exit unless $file;
@@ -101,8 +112,15 @@ sub worker_wait {
             $test->failure_output(\*STDERR);
             $test->todo_output(\*STDOUT);
 
-            @ENV{qw(DISPLAY TESTNAME OUTDIR VALGRIND STRACE COVERAGE)}
-                = ($self->{display}, basename($file), $outdir, 0, 0, 0);
+            @ENV{qw(DISPLAY TESTNAME OUTDIR VALGRIND STRACE XTRACE COVERAGE RESTART)}
+                = ($self->{display},
+                   basename($file),
+                   $outdir,
+                   $options->{valgrind},
+                   $options->{strace},
+                   $options->{xtrace},
+                   $options->{coverage},
+                   $options->{restart});
 
             package main;
             local $@;