From 4fc26e7de0ac92553a61daaa288f69ea35bf0873 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 26 Apr 2011 19:20:29 +0200 Subject: [PATCH] tests: make complete-run.pl scan tests for !NO_I3_INSTANCE!, simplify code --- testcases/complete-run.pl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/testcases/complete-run.pl b/testcases/complete-run.pl index ee21bd5d..9f201e1b 100755 --- a/testcases/complete-run.pl +++ b/testcases/complete-run.pl @@ -6,24 +6,26 @@ use warnings; use v5.10; use DateTime; use Data::Dumper; -use Cwd qw(abs_path getcwd); +use Cwd qw(abs_path); use Proc::Background; use TAP::Harness; use TAP::Parser::Aggregator; use File::Basename qw(basename); +# reads in a whole file +sub slurp { + open my $fh, '<', shift; + local $/; + <$fh>; +} + my $i3cmd = "export DISPLAY=:0; exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c " . abs_path("../i3.config"); # 1: get a list of all testcases -my $curdir = getcwd(); my @testfiles = @ARGV; -# if no files were passed on command line, run all tests -if (@testfiles == 0) { - chdir "t"; - push @testfiles, "t/$_" while (<*.t>); - chdir $curdir; -} +# if no files were passed on command line, run all tests from t/ +@testfiles = if @testfiles == 0; # 2: create an output directory for this test-run my $outdir = "testsuite-"; @@ -44,11 +46,12 @@ $aggregator->start(); for my $t (@testfiles) { my $logpath = "$outdir/i3-log-for-" . basename($t); my $cmd = "$i3cmd >$logpath 2>&1"; + my $dont_start = (slurp($t) =~ /# !NO_I3_INSTANCE!/); - my $process = Proc::Background->new($cmd); + my $process = Proc::Background->new($cmd) unless $dont_start; say "testing $t with logfile $logpath"; $harness->aggregate_tests($aggregator, [ $t ]); - kill(9, $process->pid) or die "could not kill i3"; + kill(9, $process->pid) or die "could not kill i3" unless $dont_start; } $aggregator->stop(); -- 2.39.5