From 81f4b6fc1aba971b603d64b45a6f037da9a78920 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 17 Dec 2011 11:19:31 +0000 Subject: [PATCH] =?utf8?q?complete-run:=20don=E2=80=99t=20parallelize=20mo?= =?utf8?q?re=20than=20the=20number=20of=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- testcases/complete-run.pl | 16 +++++++++------- testcases/lib/StartXDummy.pm | 5 ++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/testcases/complete-run.pl b/testcases/complete-run.pl index 247f15b0..fe652623 100755 --- a/testcases/complete-run.pl +++ b/testcases/complete-run.pl @@ -61,8 +61,16 @@ pod2usage(-verbose => 2, -exitcode => 0) if $help; @displays = split(/,/, join(',', @displays)); @displays = map { s/ //g; $_ } @displays; +# 2: get a list of all testcases +my @testfiles = @ARGV; + +# if no files were passed on command line, run all tests from t/ +@testfiles = if @testfiles == 0; + +my $numtests = scalar @testfiles; + # No displays specified, let’s start some Xdummy instances. -@displays = start_xdummy($parallel) if @displays == 0; +@displays = start_xdummy($parallel, $numtests) if @displays == 0; # 1: create an output directory for this test-run my $outdir = "testsuite-"; @@ -96,12 +104,6 @@ for my $display (@displays) { my $timingsjson = StartXDummy::slurp('.last_run_timings.json'); %timings = %{decode_json($timingsjson)} if length($timingsjson) > 0; -# 2: get a list of all testcases -my @testfiles = @ARGV; - -# if no files were passed on command line, run all tests from t/ -@testfiles = if @testfiles == 0; - # Re-order the files so that those which took the longest time in the previous # run will be started at the beginning to not delay the whole run longer than # necessary. diff --git a/testcases/lib/StartXDummy.pm b/testcases/lib/StartXDummy.pm index 0764c4ec..d9d2fd12 100644 --- a/testcases/lib/StartXDummy.pm +++ b/testcases/lib/StartXDummy.pm @@ -27,7 +27,7 @@ the Xdummy processes and a list of PIDs of the processes. my $x_socketpath = '/tmp/.X11-unix/X'; sub start_xdummy { - my ($parallel) = @_; + my ($parallel, $numtests) = @_; my @displays = (); my @childpids = (); @@ -41,6 +41,9 @@ sub start_xdummy { $parallel ||= $num_cores * 2; + # If we are running a small number of tests, don’t over-parallelize. + $parallel = $numtests if $numtests < $parallel; + # First get the last used display number, then increment it by one. # Effectively falls back to 1 if no X server is running. my ($displaynum) = map { /(\d+)$/ } reverse sort glob($x_socketpath . '*'); -- 2.39.5