]> git.sur5r.net Git - i3/i3/blobdiff - testcases/complete-run.pl
Merge branch 'master' into next
[i3/i3] / testcases / complete-run.pl
index 0769771923b1521bcbb942d08ebb95c726f3ab31..c62623f10245ae29ceab38165ed1c01156f62d49 100755 (executable)
@@ -7,7 +7,6 @@ use warnings;
 use v5.10;
 # the following are modules which ship with Perl (>= 5.10):
 use Pod::Usage;
-use Carp::Always;
 use Cwd qw(abs_path);
 use File::Basename qw(basename);
 use File::Temp qw(tempfile tempdir);
@@ -25,10 +24,15 @@ use StartXDummy;
 use StatusLine;
 # the following modules are not shipped with Perl
 use AnyEvent;
+use AnyEvent::Util;
 use AnyEvent::Handle;
 use AnyEvent::I3 qw(:all);
 use X11::XCB;
 
+# Close superfluous file descriptors which were passed by running in a VIM
+# subshell or situations like that.
+AnyEvent::Util::close_all_fds_except(0, 1, 2);
+
 # We actually use AnyEvent to make sure it loads an event loop implementation.
 # Afterwards, we overwrite SIGCHLD:
 my $cv = AnyEvent->condvar;
@@ -52,6 +56,7 @@ sub Log { say $log "@_" }
 
 my $coverage_testing = 0;
 my $valgrind = 0;
+my $strace = 0;
 my $help = 0;
 # Number of tests to run in parallel. Important to know how many Xdummy
 # instances we need to start (unless @displays are given). Defaults to
@@ -63,6 +68,7 @@ my @childpids = ();
 my $result = GetOptions(
     "coverage-testing" => \$coverage_testing,
     "valgrind" => \$valgrind,
+    "strace" => \$strace,
     "display=s" => \@displays,
     "parallel=i" => \$parallel,
     "help|?" => \$help,
@@ -133,7 +139,7 @@ status_init(displays => \@wdisplays, tests => $num);
 
 # We start tests concurrently: For each display, one test gets started. Every
 # test starts another test after completing.
-take_job($_) for @wdisplays;
+for (@wdisplays) { $cv->begin; take_job($_) }
 
 #
 # Takes a test from the beginning of @testfiles and runs it.
@@ -148,8 +154,8 @@ take_job($_) for @wdisplays;
 sub take_job {
     my ($display) = @_;
 
-    my $test = shift @testfiles;
-    return unless $test;
+    my $test = shift @testfiles
+        or return $cv->end;
 
     my $dont_start = (slurp($test) =~ /# !NO_I3_INSTANCE!/);
     my $basename = basename($test);
@@ -172,8 +178,9 @@ sub take_job {
             display => $display,
             configfile => $tmpfile,
             outdir => $outdir,
-            logpath => $logpath,
+            testname => $basename,
             valgrind => $valgrind,
+            strace => $strace,
             cv => $activate_cv
         );
 
@@ -240,7 +247,7 @@ sub take_job {
         my $output;
         open(my $spool, '>', \$output);
         my $parser = TAP::Parser->new({
-            exec => [ 'sh', '-c', qq|DISPLAY=$display LOGPATH="$logpath" OUTDIR="$outdir" VALGRIND=$valgrind /usr/bin/perl -Ilib $test| ],
+            exec => [ 'sh', '-c', qq|DISPLAY=$display TESTNAME="$basename" OUTDIR="$outdir" VALGRIND=$valgrind STRACE=$strace /usr/bin/perl -Ilib $test| ],
             spool => $spool,
             merge => 1,
         });
@@ -281,7 +288,7 @@ sub take_job {
 
                         undef $_ for @watchers;
                         if (@done == $num) {
-                            $cv->send;
+                            $cv->end;
                         } else {
                             take_job($display);
                         }
@@ -355,7 +362,12 @@ complete-run.pl will start (num_cores * 2) Xdummy instances.
 =item B<--valgrind>
 
 Runs i3 under valgrind to find memory problems. The output will be available in
-C<latest/valgrind.log>.
+C<latest/valgrind-for-$test.log>.
+
+=item B<--strace>
+
+Runs i3 under strace to trace system calls. The output will be available in
+C<latest/strace-for-$test.log>.
 
 =item B<--coverage-testing>