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);
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;
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
my $result = GetOptions(
"coverage-testing" => \$coverage_testing,
"valgrind" => \$valgrind,
+ "strace" => \$strace,
"display=s" => \@displays,
"parallel=i" => \$parallel,
"help|?" => \$help,
# 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.
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);
display => $display,
configfile => $tmpfile,
outdir => $outdir,
- logpath => $logpath,
+ testname => $basename,
valgrind => $valgrind,
+ strace => $strace,
cv => $activate_cv
);
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,
});
undef $_ for @watchers;
if (@done == $num) {
- $cv->send;
+ $cv->end;
} else {
take_job($display);
}
=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>