From 539cb834211ec10cb5b7db69f4d3bc65de7bc4c1 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Fri, 18 Mar 2022 16:09:22 +0100 Subject: [PATCH] Add make targets `gen-golden-all` and `golden-diff-all` These targets use a static list of test instances in make variable `test_instances`. The contents of this variable are generated from the modulesync parameter `testMatrix.entries`. We use a generic recursive make target based on the `test_instances` make variable to implement the new targets. This allows us to reuse the existing `golden-diff` and `gen-golden` targets. The new targets are only added for components which have golden and matrix tests configured and which have migrated their matrix test configuration to modulesync parameter `testMatrix`. --- moduleroot/Makefile.erb | 14 ++++++++++++++ moduleroot/Makefile.vars.mk.erb | 3 +++ 2 files changed, 17 insertions(+) diff --git a/moduleroot/Makefile.erb b/moduleroot/Makefile.erb index 120d060..151895f 100644 --- a/moduleroot/Makefile.erb +++ b/moduleroot/Makefile.erb @@ -75,6 +75,20 @@ gen-golden: clean .compile ## Update the reference version for target `golden-di golden-diff: commodore_args += -f tests/$(instance).yml golden-diff: clean .compile ## Diff compile output against the reference version. Review output and run `make gen-golden golden-diff` if this target fails. @git diff --exit-code --minimal --no-index -- tests/golden/$(instance) compiled/ +<%- if !@configs['testMatrix'].empty? && !@configs['testMatrix']['entries'].empty? -%> + +.PHONY: golden-diff-all +golden-diff-all: recursive_target=golden-diff +golden-diff-all: $(test_instances) ## Run golden-diff for all instances. Note: this doesn't work when running make with multiple parallel jobs (-j != 1). + +.PHONY: gen-golden-all +gen-golden-all: recursive_target=gen-golden +gen-golden-all: $(test_instances) ## Run gen-golden for all instances. Note: this doesn't work when running make with multiple parallel jobs (-j != 1). + +.PHONY: $(test_instances) +$(test_instances): + $(MAKE) $(recursive_target) -e instance=$(basename $(@F)) +<%- end -%> <%- end -%> .PHONY: clean diff --git a/moduleroot/Makefile.vars.mk.erb b/moduleroot/Makefile.vars.mk.erb index c353f73..95c4e5d 100644 --- a/moduleroot/Makefile.vars.mk.erb +++ b/moduleroot/Makefile.vars.mk.erb @@ -34,3 +34,6 @@ COMMODORE_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) docker.io/projects JB_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) --entrypoint /usr/local/bin/jb docker.io/projectsyn/commodore:latest install instance ?= defaults +<%- if @configs['feature_goldenTests'] && !@configs['testMatrix'].empty? && !@configs['testMatrix']['entries'].empty? -%> +test_instances =<%- @configs['testMatrix']['entries'].each do |entry| %> tests/<%= entry %>.yml<% end %> +<%- end -%>