Skip to content

Commit

Permalink
Greatly speed up test speed with -j
Browse files Browse the repository at this point in the history
The tests were waiting for the test group to finish before
they could continue with the next test group. Now "core"
and "all" targets directly depend on individual test cases,
allowing parallel Make to get to the next tests quicker and
removing 1/3rd of the total run time.

  make check -j8 -k  5790,16s user 1207,08s system 627% cpu 18:35,49 total
  make check -j8 -k  6250,13s user 1326,77s system 972% cpu 12:59,16 total
  • Loading branch information
essen committed Nov 13, 2024
1 parent 4d3d3fa commit e903cc8
Show file tree
Hide file tree
Showing 30 changed files with 103 additions and 95 deletions.
18 changes: 13 additions & 5 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ endef

.PHONY: all clean init

all:: core
all::
$t :

clean::
$t rm -rf erl_crash.dump packages/ $(filter-out test_rebar_git/,$(wildcard test_*/))
Expand All @@ -146,26 +147,33 @@ export REBAR3_GIT

.PHONY: core

define include_core
core:: core-$1
CORE_TARGETS :=
PLUGINS_TARGETS :=

define include_core
include core_$1.mk

CORE_TARGETS += $$(core_$1_TARGETS)

endef

$(eval $(foreach t,$(patsubst %.mk,%,$(patsubst core_%,%,$(wildcard core_*.mk))),$(call include_core,$t)))

# Plugins.

define include_plugin
all:: $1

include plugin_$1.mk

PLUGINS_TARGETS += $$($1_TARGETS)

endef

$(eval $(foreach t,$(patsubst %.mk,%,$(patsubst plugin_%,%,$(wildcard plugin_*.mk))),$(call include_plugin,$t)))

core:: $(CORE_TARGETS)

all:: $(CORE_TARGETS) $(PLUGINS_TARGETS)

# Packages.

PACKAGES = $(foreach pkg,$(sort $(wildcard ../index/*.mk)),$(notdir $(basename $(pkg))))
Expand Down
6 changes: 3 additions & 3 deletions test/core_app.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: Building applications.

CORE_APP_TARGETS = $(call list_targets,core-app)
core_app_TARGETS = $(call list_targets,core-app)

.PHONY: core-app $(CORE_APP_TARGETS)
.PHONY: core-app $(core_app_TARGETS)

core-app: $(CORE_APP_TARGETS)
core-app: $(core_app_TARGETS)

ifdef LEGACY
core-app-appsrc-change: init
Expand Down
6 changes: 3 additions & 3 deletions test/core_apps.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: Multi-applications.

CORE_APPS_TARGETS = $(call list_targets,core-apps)
core_apps_TARGETS = $(call list_targets,core-apps)

.PHONY: core-apps $(CORE_APPS_TARGETS)
.PHONY: core-apps $(core_apps_TARGETS)

core-apps: $(CORE_APPS_TARGETS)
core-apps: $(core_apps_TARGETS)

core-apps-build: init

Expand Down
6 changes: 3 additions & 3 deletions test/core_autopatch.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: Autopatch.

CORE_AUTOPATCH_TARGETS = $(call list_targets,core-autopatch)
core_autopatch_TARGETS = $(call list_targets,core-autopatch)

.PHONY: core-autopatch $(CORE_AUTOPATCH_TARGETS)
.PHONY: core-autopatch $(core_autopatch_TARGETS)

core-autopatch: $(CORE_AUTOPATCH_TARGETS)
core-autopatch: $(core_autopatch_TARGETS)

core-autopatch-extended: init

Expand Down
6 changes: 3 additions & 3 deletions test/core_compat.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#
# Note: autopatch functionality is covered separately.

CORE_COMPAT_TARGETS = $(call list_targets,core-compat)
core_compat_TARGETS = $(call list_targets,core-compat)

REBAR3_BINARY = https://s3.amazonaws.com/rebar3/rebar3

.PHONY: core-compat $(CORE_COMPAT_TARGETS)
.PHONY: core-compat $(core_compat_TARGETS)

core-compat: $(CORE_COMPAT_TARGETS)
core-compat: $(core_compat_TARGETS)

core-compat-auto-rebar: init

Expand Down
6 changes: 3 additions & 3 deletions test/core_deps.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: Packages and dependencies.

CORE_DEPS_TARGETS = $(call list_targets,core-deps)
core_deps_TARGETS = $(call list_targets,core-deps)

.PHONY: core-deps $(CORE_DEPS_TARGETS)
.PHONY: core-deps $(core_deps_TARGETS)

core-deps: $(CORE_DEPS_TARGETS)
core-deps: $(core_deps_TARGETS)

ifneq ($(PLATFORM),msys2)
core-deps-build-c-8cc: init
Expand Down
6 changes: 3 additions & 3 deletions test/core_makedep.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: COMPILE_FIRST dependencies generation.

CORE_MAKEDEP_TARGETS = $(call list_targets,core-makedep)
core_makedep_TARGETS = $(call list_targets,core-makedep)

.PHONY: core-makedep $(CORE_MAKEDEP_TARGETS)
.PHONY: core-makedep $(core_makedep_TARGETS)

core-makedep: $(CORE_MAKEDEP_TARGETS)
core-makedep: $(core_makedep_TARGETS)

core-makedep-behavior: init

Expand Down
6 changes: 3 additions & 3 deletions test/core_misc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#
# The miscellaneous tests use the prefix "core-", not "core-misc-".

CORE_MISC_TARGETS = $(filter-out core-misc,$(call list_targets,core))
core_misc_TARGETS = $(filter-out core-misc,$(call list_targets,core))

.PHONY: core-misc $(CORE_MISC_TARGETS)
.PHONY: core-misc $(core_misc_TARGETS)

core-misc: $(CORE_MISC_TARGETS)
core-misc: $(core_misc_TARGETS)

core-clean-crash-dump: init

Expand Down
6 changes: 3 additions & 3 deletions test/core_plugins.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: External plugins.

CORE_PLUGINS_TARGETS = $(call list_targets,core-plugins)
core_plugins_TARGETS = $(call list_targets,core-plugins)

.PHONY: core-plugins $(CORE_PLUGINS_TARGETS)
.PHONY: core-plugins $(core_plugins_TARGETS)

core-plugins: $(CORE_PLUGINS_TARGETS)
core-plugins: $(core_plugins_TARGETS)

core-plugins-all: init

Expand Down
6 changes: 3 additions & 3 deletions test/core_query.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: Querying dependencies.

CORE_QUERY_TARGETS = $(call list_targets,core-query)
core_query_TARGETS = $(call list_targets,core-query)

.PHONY: core-query $(CORE_QUERY_TARGETS)
.PHONY: core-query $(core_query_TARGETS)

core-query: $(CORE_QUERY_TARGETS)
core-query: $(core_query_TARGETS)

core-query-deps: init

Expand Down
6 changes: 3 additions & 3 deletions test/core_upgrade.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Core: Erlang.mk upgrade.

CORE_UPGRADE_TARGETS = $(call list_targets,core-upgrade)
core_upgrade_TARGETS = $(call list_targets,core-upgrade)

.PHONY: core-upgrade $(CORE_UPGRADE_TARGETS)
.PHONY: core-upgrade $(core_upgrade_TARGETS)

core-upgrade: $(CORE_UPGRADE_TARGETS)
core-upgrade: $(core_upgrade_TARGETS)

core-upgrade-changelog: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_asciidoc.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# AsciiDoc plugin.

ASCIIDOC_TARGETS = $(call list_targets,asciidoc)
asciidoc_TARGETS = $(call list_targets,asciidoc)

.PHONY: asciidoc $(ASCIIDOC_TARGETS)
.PHONY: asciidoc $(asciidoc_TARGETS)

asciidoc: $(ASCIIDOC_TARGETS)
asciidoc: $(asciidoc_TARGETS)

# Disable the Asciidoc tests requiring the DocBook toolchain
# when Asciidoc is not installed. The toolchain is too heavy for CI.
Expand Down
6 changes: 3 additions & 3 deletions test/plugin_bootstrap.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Bootstrap plugin.

BOOTSTRAP_TARGETS = $(call list_targets,bootstrap)
bootstrap_TARGETS = $(call list_targets,bootstrap)

.PHONY: bootstrap $(BOOTSTRAP_TARGETS)
.PHONY: bootstrap $(bootstrap_TARGETS)

bootstrap: $(BOOTSTRAP_TARGETS)
bootstrap: $(bootstrap_TARGETS)

bootstrap-app: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_c_src.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# C source plugin.

C_SRC_TARGETS = $(call list_targets,c-src)
c_src_TARGETS = $(call list_targets,c-src)

.PHONY: c-src $(C_SRC_TARGETS)
.PHONY: c-src $(c_src_TARGETS)

c-src: $(C_SRC_TARGETS)
c-src: $(c_src_TARGETS)
c_src: c-src

ifeq ($(PLATFORM),msys2)
Expand Down
6 changes: 3 additions & 3 deletions test/plugin_concuerror.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Concuerror plugin.

CONCUERROR_TARGETS = $(call list_targets,concuerror)
concuerror_TARGETS = $(call list_targets,concuerror)

.PHONY: concuerror $(CONCUERROR_TARGETS)
.PHONY: concuerror $(concuerror_TARGETS)

concuerror: $(CONCUERROR_TARGETS)
concuerror: $(concuerror_TARGETS)

concuerror-app: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_cover.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Common Test plugin.

COVER_TARGETS = $(call list_targets,cover)
cover_TARGETS = $(call list_targets,cover)

.PHONY: cover $(COVER_TARGETS)
.PHONY: cover $(cover_TARGETS)

cover: $(COVER_TARGETS)
cover: $(cover_TARGETS)

cover-ct: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_ct.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Common Test plugin.

CT_TARGETS = $(call list_targets,ct)
ct_TARGETS = $(call list_targets,ct)

.PHONY: ct $(CT_TARGETS)
.PHONY: ct $(ct_TARGETS)

ct: $(CT_TARGETS)
ct: $(ct_TARGETS)

ct-all: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_dialyzer.mk
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Dialyzer plugin.

DIALYZER_TARGETS = $(call list_targets,dialyzer)
dialyzer_TARGETS = $(call list_targets,dialyzer)

ifneq ($(shell which sem 2>/dev/null),)
DIALYZER_MUTEX = sem --fg --id dialyzer
endif

.PHONY: dialyzer $(DIALYZER_TARGETS)
.PHONY: dialyzer $(dialyzer_TARGETS)

dialyzer: $(DIALYZER_TARGETS)
dialyzer: $(dialyzer_TARGETS)

dialyzer-app: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_edoc.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# EDoc plugin.

EDOC_TARGETS = $(call list_targets,edoc)
edoc_TARGETS = $(call list_targets,edoc)

.PHONY: edoc $(EDOC_TARGETS)
.PHONY: edoc $(edoc_TARGETS)

edoc: $(EDOC_TARGETS)
edoc: $(edoc_TARGETS)

edoc-build: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_erlydtl.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ErlyDTL plugin.

ERLYDTL_TARGETS = $(call list_targets,erlydtl)
erlydtl_TARGETS = $(call list_targets,erlydtl)

.PHONY: erlydtl $(ERLYDTL_TARGETS)
.PHONY: erlydtl $(erlydtl_TARGETS)

erlydtl: $(ERLYDTL_TARGETS)
erlydtl: $(erlydtl_TARGETS)

erlydtl-compile: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_escript.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Escript plugin.

ESCRIPT_TARGETS = $(call list_targets,escript)
escript_TARGETS = $(call list_targets,escript)

.PHONY: escript $(ESCRIPT_TARGETS)
.PHONY: escript $(escript_TARGETS)

escript: $(ESCRIPT_TARGETS)
escript: $(escript_TARGETS)

escript-build: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_eunit.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# EUnit plugin.

EUNIT_TARGETS = $(call list_targets,eunit)
eunit_TARGETS = $(call list_targets,eunit)

.PHONY: eunit $(EUNIT_TARGETS)
.PHONY: eunit $(eunit_TARGETS)

eunit: $(EUNIT_TARGETS)
eunit: $(eunit_TARGETS)

eunit-all: init

Expand Down
6 changes: 3 additions & 3 deletions test/plugin_hex.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# be started and available on port 4000, and the HEX=1 variable
# must be set.

HEX_TARGETS = $(call list_targets,hex)
hex_TARGETS = $(call list_targets,hex)

.PHONY: hex $(HEX_TARGETS)
.PHONY: hex $(hex_TARGETS)

hex: $(HEX_TARGETS)
hex: $(hex_TARGETS)

ifeq ($(shell netcat -z localhost 4000 && echo ok),ok)
hex-user-create: init
Expand Down
6 changes: 3 additions & 3 deletions test/plugin_proper.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# PropEr plugin.

PROPER_TARGETS = $(call list_targets,proper)
proper_TARGETS = $(call list_targets,proper)

.PHONY: proper $(PROPER_TARGETS)
.PHONY: proper $(proper_TARGETS)

proper: $(PROPER_TARGETS)
proper: $(proper_TARGETS)

proper-test-dir: init

Expand Down
Loading

0 comments on commit e903cc8

Please sign in to comment.