This is an automated email from the ASF dual-hosted git repository. jan pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 29e3fb90fe5e39580fda475b54eb79f07390eb21 Author: Jan Lehnardt <[email protected]> AuthorDate: Thu Dec 4 10:23:06 2025 +0100 feat: allow for parallel execution of `make eunit` sub-targets When called with -jN for N>1, make will run `rebar -r eunit` for all src/* Erlang apps (without the default skipped ones) up to the limit of N times in parallel. This is best used with GNU Make, as it allows for controlling the output of each subtask to be grouped. BSD Make has no such feature and interleaves all parallel target’s output, making it hard to read. For example: gmake -j2 --output-sync=target will run two test suites in parallel and keep their respective outputs separated. It does this by buffering all output before a task is done that means for the first few tests, you don’t see output as you do with serial execution. On my machine I can run up to -j6 relatively stable, making use of all 14 cores. Beyond that, Spurious errors can occur. I’ll file those separately. -j2 shows an almost 2x speed improvement, as expected and things scale relatively linarly up until ~2.5 minutes of runtime, which seems to be a lower bound with all our various setup and wait bits. For comparison, -j1, that is serial execution takes about 10.5 minutes on this machine. Use with care in CI, but definitely use on your local dev machine. --- Makefile | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 279460f93..eaa443f2f 100644 --- a/Makefile +++ b/Makefile @@ -168,23 +168,34 @@ check: all @$(MAKE) nouveau-test ifdef apps -subdirs = $(apps) +SUBDIRS = $(apps) else -subdirs=$(shell ls src) +SUBDIRS=$(shell ls src) endif -.PHONY: eunit +# Used for comparing behaviour against he new `eunit` target, delete once we +# are happy with the new `eunit`. +.PHONY: old-eunit +old-eunit: export BUILDDIR = $(CURDIR) +old-eunit: export ERL_AFLAGS = -config $(CURDIR)/rel/files/eunit.config +old-eunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(CURDIR)/bin/couchjs $(CURDIR)/share/server/main.js +old-eunit: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1 +old-eunit: + @COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) setup_eunit 2> /dev/null + @for dir in $(SUBDIRS); do \ + COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) -r eunit $(EUNIT_OPTS) apps=$$dir || exit 1; \ + done + # target: eunit - Run EUnit tests, use EUNIT_OPTS to provide custom options +.PHONY: eunit $(SUBDIRS) eunit: export BUILDDIR = $(CURDIR) eunit: export ERL_AFLAGS = -config $(CURDIR)/rel/files/eunit.config eunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(CURDIR)/bin/couchjs $(CURDIR)/share/server/main.js eunit: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1 -eunit: couch - @COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) setup_eunit 2> /dev/null - @for dir in $(subdirs); do \ - COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) -r eunit $(EUNIT_OPTS) apps=$$dir || exit 1; \ - done +eunit: ${SUBDIRS} +$(SUBDIRS): setup-eunit + @COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) -r eunit $(EUNIT_OPTS) apps=$@ #|| exit 1 setup-eunit: export BUILDDIR = $(CURDIR) setup-eunit: export ERL_AFLAGS = -config $(CURDIR)/rel/files/eunit.config
