From ac54a7bca6352a851294c492fc3ebb6b150f6ec9 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Thu, 2 Jul 2026 14:41:56 +0200 Subject: [PATCH 1/3] make: Make target "test" depend on target "all" Every directory should have a test target, and the test target should depend on all so that all files are generated that might be needed for testing. This commit fixes some missing targets, and adds some missing dependencies. Signed-off-by: Jan Lindemann --- make/bin.mk | 3 ++- make/cleandirs.mk | 1 + make/conf.mk | 2 +- make/dummy-topdir.mk | 2 +- make/exe.mk | 2 +- make/gettext.mk | 2 +- make/htdocs.mk | 2 +- make/make.mk | 2 +- make/profile.mk | 2 +- make/py-run.mk | 2 +- make/run.mk | 1 + make/scripts-targets.mk | 2 +- make/std-targets.mk | 2 +- make/subdirs.mk | 1 + make/test-exe.mk | 2 +- make/text.mk | 2 +- make/tmpl.mk | 2 +- make/topdir.mk | 6 ++++-- 18 files changed, 22 insertions(+), 16 deletions(-) diff --git a/make/bin.mk b/make/bin.mk index 863cb660..98dd572d 100644 --- a/make/bin.mk +++ b/make/bin.mk @@ -5,7 +5,8 @@ include $(JWBDIR)/make/defs.mk +all: all install: clean distclean: $(RM) -rf $(filter-out $(LOCAL_MKFILES) CVS debug release,$(wildcard *)) -test: +test: all diff --git a/make/cleandirs.mk b/make/cleandirs.mk index d455e3be..3db66e30 100644 --- a/make/cleandirs.mk +++ b/make/cleandirs.mk @@ -4,6 +4,7 @@ all: do.all install: do.install clean: do.clean distclean: do.distclean +test: include $(JWBDIR)/make/defs.mk include $(JWBDIR)/make/defs-dirs.mk diff --git a/make/conf.mk b/make/conf.mk index e5158821..651ceb76 100644 --- a/make/conf.mk +++ b/make/conf.mk @@ -6,7 +6,7 @@ all: clean: clean.conf install: install_CFG install_files_SYSCFG install_files_LOGROT install_files_CRONTAB install_files_RSYSLOG \ install_files_APACHE_CONF install_files_SYSTEMD install_files_INIT install_files_TMPFILES $(CONF_D) -test: +test: all clean.conf: $(RM) -rf *~ .*.swp *.done diff --git a/make/dummy-topdir.mk b/make/dummy-topdir.mk index ad6b6c0e..8d9c1f41 100644 --- a/make/dummy-topdir.mk +++ b/make/dummy-topdir.mk @@ -8,6 +8,6 @@ install: clean: distclean: check: -test: +test: all get-%: pkg-%: diff --git a/make/exe.mk b/make/exe.mk index 1062b086..94d4e1be 100644 --- a/make/exe.mk +++ b/make/exe.mk @@ -9,7 +9,7 @@ include $(JWBDIR)/make/dev-utils.mk all: $(EXE) $(BUILD_EXE_BIN) $(STRIP_DONE) install: $(INSTALLED_EXE) $(INSTALLED_EXE_BIN) -run test: all.dirs $(EXE) $(EXE_BIN) +run test: all all.dirs $(EXE) $(EXE_BIN) strace: $(EXE) $(EXE_BIN) clean: execlean localclean profclean diff --git a/make/gettext.mk b/make/gettext.mk index dac41d44..d33bd81f 100644 --- a/make/gettext.mk +++ b/make/gettext.mk @@ -22,7 +22,7 @@ clean: clean-mo $(RM) -rf *~ .*.swp install: install_MO distclean: clean -test: +test: all extract: $(GETTEXT_POT) clean-mo: diff --git a/make/htdocs.mk b/make/htdocs.mk index caa47093..e6616497 100644 --- a/make/htdocs.mk +++ b/make/htdocs.mk @@ -30,7 +30,7 @@ include $(JWBDIR)/make/dev-utils.mk all: $(LESS_GENERATED_CSS) lint install: install_HTML clean: textclean localclean doneclean clean.lesscpy -test: +test: all %.css: %.less $(LESS_CPY) $< > $@.tmp diff --git a/make/make.mk b/make/make.mk index d71e0a23..f350d46b 100644 --- a/make/make.mk +++ b/make/make.mk @@ -42,7 +42,7 @@ all: build_PKG_CONFIG endif install: $(DEVEL_TARGETS) clean: textclean localclean doneclean clean.pkg-config -test: +test: all $(INSTALL_PCKG_DEPS_DIR)/$(PROJECT).mk: pckg-deps.mk mkdir -p $(dir $@) diff --git a/make/profile.mk b/make/profile.mk index 70e22a01..e21681f5 100644 --- a/make/profile.mk +++ b/make/profile.mk @@ -18,7 +18,7 @@ include $(JWBDIR)/make/rules.mk all: $(PROFILE) install: install_files_PROFILE clean: allclean localclean doneclean textclean clean.profile -test: +test: all path-%.sh: @echo "export PATH=\$$PATH:$(INSTALL_EXEDIR)" > $@.tmp diff --git a/make/py-run.mk b/make/py-run.mk index 5c7bfe1f..2c4d7950 100644 --- a/make/py-run.mk +++ b/make/py-run.mk @@ -10,7 +10,7 @@ all: install: clean: distclean: -test: +test: all run: $(PYTHON) $(EXE) $(EXE_ARGS) diff --git a/make/run.mk b/make/run.mk index 5efffd73..95fd8b91 100644 --- a/make/run.mk +++ b/make/run.mk @@ -66,6 +66,7 @@ all: install: clean: runclean localclean distclean: +test: all run-deps: all $(RM) -f core core.* vgcore vgcore.* diff --git a/make/scripts-targets.mk b/make/scripts-targets.mk index 243aca2e..4b0a35d8 100644 --- a/make/scripts-targets.mk +++ b/make/scripts-targets.mk @@ -1,7 +1,7 @@ all: build_EXE build_CGI install: install_files_INIT install_EXE install_files_CGI install_files_SYSCFG clean:allclean localclean doneclean textclean clean.init -test: +test: all ifeq ($(INSTALL_HOME_BIN_WRAPPERS),true) install: install-home-bin diff --git a/make/std-targets.mk b/make/std-targets.mk index 95511e96..9523e0e4 100644 --- a/make/std-targets.mk +++ b/make/std-targets.mk @@ -8,4 +8,4 @@ clean: clean.std-targets clean.std-targets: $(RM) -rf *~ .*.swp *.done distclean: clean -test: +test: all diff --git a/make/subdirs.mk b/make/subdirs.mk index a30c2654..bde0bf6d 100644 --- a/make/subdirs.mk +++ b/make/subdirs.mk @@ -4,6 +4,7 @@ include $(JWBDIR)/make/defs-dirs.mk all: clean: clean.var distclean: clean.var distclean.var +test: all install clean distclean test: ifneq ($(SUBDIRS_TO_ITERATE),) diff --git a/make/test-exe.mk b/make/test-exe.mk index 2c9a6e3e..d5dc7294 100644 --- a/make/test-exe.mk +++ b/make/test-exe.mk @@ -13,7 +13,7 @@ clean: execlean localclean profclean testclean distclean: run test: all.dirs $(EXE) $(EXE_BIN) strace: $(EXE) $(EXE_BIN) -test: test.done +test: all test.done test.done: if ! 2>&1 make run > test.out 2>&1; then \ diff --git a/make/text.mk b/make/text.mk index e4f6d9c1..2a14bfb7 100644 --- a/make/text.mk +++ b/make/text.mk @@ -10,4 +10,4 @@ all: install: distclean: textclean localclean clean: textclean localclean -test: +test: all diff --git a/make/tmpl.mk b/make/tmpl.mk index 425e3da8..137aeb5c 100644 --- a/make/tmpl.mk +++ b/make/tmpl.mk @@ -19,4 +19,4 @@ include $(JWBDIR)/make/rules.mk all: install: install_TMPL clean: textclean localclean doneclean -test: +test: all diff --git a/make/topdir.mk b/make/topdir.mk index a4a4dd7f..238b5837 100644 --- a/make/topdir.mk +++ b/make/topdir.mk @@ -5,6 +5,7 @@ FORCE \ all \ format \ + canonicalize-remotes \ check-syntax \ check-format \ check \ @@ -42,7 +43,7 @@ pkg-install-release-deps \ pkg-install-testbuild-deps \ recache-vars \ - canonicalize-remotes + test ifeq ($(ORDERED_SUBDIRS),) SUBDIRS ?= $(dir $(wildcard $(addsuffix /Makefile,\ @@ -95,6 +96,7 @@ ifneq ($(SUBDIRS_TO_ITERATE),) endif all: topdir config +test: all include $(JWBDIR)/make/dirs.mk include $(JWBDIR)/make/pkg-dist.mk @@ -115,7 +117,7 @@ TD_COPY_FILES ?= $(filter-out Makefile,$(notdir $(wildcard $(TD_CO TD_COPY_SRC_PATH = $(subst :,$(space),$(JW_PKG_TOPDIR_COPY_PATH)) TD_GENERATE_FILES += $(TD_COPY_FILES) -all: +test: all format: topdir check-syntax: topdir check-format: topdir -- 2.55.0 From 52f34a915d0b80100e174fad0f8a2968f9fbc27e Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Thu, 2 Jul 2026 14:49:08 +0200 Subject: [PATCH 2/3] py-test.mk: Add file Add a dedicated py-test.mk for running tests with pytest instead of python. The commit introduces a new variable PYTHON_RUNNER, which is then used by py-run.mk to do it's usual thing. Running pytest is similar enough to running Python programs to keep the rest of the machinery and prevent redundancy from creeping in. Signed-off-by: Jan Lindemann --- make/py-run.mk | 3 ++- make/py-test.mk | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 make/py-test.mk diff --git a/make/py-run.mk b/make/py-run.mk index 2c4d7950..43c210ed 100644 --- a/make/py-run.mk +++ b/make/py-run.mk @@ -5,6 +5,7 @@ include $(JWBDIR)/make/py-defs.mk EXE ?= $(firstword $(wildcard main.py runme.py test.py *.py)) EXE_ARGS ?= +PYTHON_RUNNER ?= $(PYTHON) all: install: @@ -13,7 +14,7 @@ distclean: test: all run: - $(PYTHON) $(EXE) $(EXE_ARGS) + $(PYTHON_RUNNER) $(EXE) $(EXE_ARGS) run.sh: echo -e "#!/bin/bash\n\nexport PYTHONPATH=$(PYTHONPATH)\nset -x\nexec $(PYTHON) $(EXE)" '"$$@"' > $@.tmp diff --git a/make/py-test.mk b/make/py-test.mk new file mode 100644 index 00000000..3d77f7e0 --- /dev/null +++ b/make/py-test.mk @@ -0,0 +1,6 @@ +PYTHON_RUNNER ?= pytest -v + +include $(JWBDIR)/make/py-run.mk + +all: +test: run -- 2.55.0 From 0c92d942ecc2d0905d1b94293801427607bbe094 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Thu, 2 Jul 2026 17:20:08 +0200 Subject: [PATCH 3/3] py-test.mk: Generate conftest.py Generate a standard conftest.py, mostly for customizing pytest's bombastic test header, which otherwise lets the more informative make output look too pale in comparison. Signed-off-by: Jan Lindemann --- make/py-test.mk | 19 ++++++++++++++++++- scripts/python-tools.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/make/py-test.mk b/make/py-test.mk index 3d77f7e0..69634d8f 100644 --- a/make/py-test.mk +++ b/make/py-test.mk @@ -1,6 +1,23 @@ -PYTHON_RUNNER ?= pytest -v +PY_CONFTEST ?= conftest.py +PY_UPDATE_PY_CONFTEST ?= true +ifeq ($(PY_UPDATE_PY_CONFTEST),true) + PY_GENERATED += $(PY_CONFTEST) +endif + +PY_CONFTEST_CMD ?= /bin/bash $(JWB_SCRIPT_DIR)/python-tools.sh create-conftest-py +PY_TEST_ARGS ?= -v +PYTHON_RUNNER := pytest $(PY_TEST_ARGS) include $(JWBDIR)/make/py-run.mk all: test: run +run: $(PY_GENERATED) + +$(PY_CONFTEST): + $(PY_CONFTEST_CMD) > $@.tmp + mv $@.tmp $@ + +clean: clean.generated +clean.generated: + rm -f $(PY_GENERATED) diff --git a/scripts/python-tools.sh b/scripts/python-tools.sh index 56950a0f..0b189d7b 100644 --- a/scripts/python-tools.sh +++ b/scripts/python-tools.sh @@ -32,6 +32,39 @@ module_path() fi } +cmd_create_conftest_py() +{ + cat <<-'EOT' + import os + import sys + import shutil + + def pytest_configure(config): + import _pytest.terminal + import _pytest.timing as timing + + # orig = _pytest.terminal.TerminalReporter.pytest_sessionstart + + def patched(self, session): + width = shutil.get_terminal_size().columns + d = os.path.basename(os.getcwd()) + text = f"Running pytest for {d}" + # Center text within terminal width, matching pytest footer style + padding = width - len(text) - 2 + if padding > 0: + left = padding // 2 + right = padding - left + banner = "=" * left + f" {text} " + "=" * right + else: + banner = text + print(banner, file = sys.stderr) + self._session = session + self._session_start = timing.Instant() + + _pytest.terminal.TerminalReporter.pytest_sessionstart = patched +EOT +} + cmd_create_init() { __add_seen() { -- 2.55.0