This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=5affe2bdccec4a14ddf66eb2ec4d3578aafdf179 commit 5affe2bdccec4a14ddf66eb2ec4d3578aafdf179 Author: Guillem Jover <[email protected]> AuthorDate: Fri Jul 4 04:05:55 2025 +0200 build: Automatically set test parallelism from make parallelism Instead of having to specify the parallelism twice, with «make -j» and then also with TEST_PARALLEL, infer the latter based on the make(1) parallel jobs running. On BSD make we can use the internal .MAKE.JOBS variable, and on GNU make we can get the -j argument from the MAKEFLAGS variable which gets exported to the make child processes. --- build-aux/autotest.am | 2 +- build-aux/get-make-jobs | 38 ++++++++++++++++++++++++++++++++++++++ build-aux/tap.am | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/build-aux/autotest.am b/build-aux/autotest.am index 19054c5fa..54ac39453 100644 --- a/build-aux/autotest.am +++ b/build-aux/autotest.am @@ -5,7 +5,7 @@ DISTCLEANFILES += at/atconfig AUTOTEST_DEPS = at/atconfig at/atlocal $(TESTSUITE) TEST_VERBOSE ?= 0 -TEST_PARALLEL ?= 1 +TEST_PARALLEL ?= `$(top_srcdir)/build-aux/run-script build-aux/get-make-jobs $(.MAKE.JOBS)` TEST_VERBOSE_OPT = $(TEST_VERBOSE:0=) diff --git a/build-aux/get-make-jobs b/build-aux/get-make-jobs new file mode 100755 index 000000000..5d8e6961b --- /dev/null +++ b/build-aux/get-make-jobs @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use v5.36; + +use Scalar::Util qw( + looks_like_number +); +use List::Util qw( + any +); + +use Dpkg::SysInfo qw( + get_num_processors +); + +my $arg = $ARGV[0] // 0; + +if (looks_like_number($arg) && $arg > 0) { + say $arg; + exit 0; +} elsif (length $ENV{MAKEFLAGS}) { + my @flags = split ' ', $ENV{MAKEFLAGS}; + + foreach my $flag (@flags) { + if ($flag =~ m{^-j(.*)$}) { + my $jobs = $1; + + if (not length $jobs) { + $jobs = get_num_processors(); + } + + say $jobs; + exit 0; + } + } +} + +say '1'; diff --git a/build-aux/tap.am b/build-aux/tap.am index f05d4ba23..d2410f92d 100644 --- a/build-aux/tap.am +++ b/build-aux/tap.am @@ -10,7 +10,7 @@ # test_data - list of test data files TEST_VERBOSE ?= 0 -TEST_PARALLEL ?= 1 +TEST_PARALLEL ?= `$(top_srcdir)/build-aux/run-script build-aux/get-make-jobs $(.MAKE.JOBS)` tap-clean: [ -z "$(test_tmpdir)" ] || rm -fr $(test_tmpdir) -- Dpkg.Org's dpkg

