From 31022d71fbb5d55010c72154b65d84ddfbfe3312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Mon, 30 Jan 2023 08:43:12 -0500 Subject: [PATCH] Change run-with function to error instead of warn The 'make test' command will now error when dependencies are not installed. For py.test I made it use a virtualenv install of py.test and requests modules. The Makefile looks for a Python 3 binary and errors otherwise. I had python3 installed locally but not py.test. I didn't feel like that should stop me from installing it temporarily on the fly like we do for bpan. --- .gitignore | 1 + .setup.mk | 7 ++++++- Makefile | 13 +++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c6f46de0..65aedf79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.bpan/ +/.venv/ /tests/__pycache__/ /__pycache__/ diff --git a/.setup.mk b/.setup.mk index 2f4b1174..94b8f865 100644 --- a/.setup.mk +++ b/.setup.mk @@ -6,9 +6,14 @@ SHELL := bash define run-with $(if $(shell command -v $1), \ $3, \ -$(warning WARNING: Can't 'make $2'. No '$1' command found.)) +$(error ERROR: Can't 'make $2'. No '$1' command found.)) endef ifeq (,$(shell git diff --stat)) GIT_STATUS_IS_CLEAN := 1 endif + +PYTHON := $(shell command -v python3 || command -v python) +ifeq (,$(and $(PYTHON),$(findstring Python 3.,$(shell $(PYTHON) --version)))) + $(error Python 3 not installed for testing) +endif diff --git a/Makefile b/Makefile index f414acdc..8da52148 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,9 @@ endif endif BPAN := .bpan +VENV := .venv +export PATH := .venv/bin:$(PATH) #------------------------------------------------------------------------------ # User targets @@ -23,9 +25,8 @@ test-bash: $(BPAN) $(call run-with,prove,$@,\ prove -r $(if $v,-v )$(test)) -test-python: - $(call run-with,py.test,$@,\ - py.test tests) +test-python: $(VENV) + py.test tests test-online: dry_run=1 bash -x ./openqa-label-known-issues-multi < ./tests/incompletes @@ -48,7 +49,7 @@ update-deps: clean: $(RM) job_post_response - $(RM) -r $(BPAN) + $(RM) -r $(BPAN) $(VENV) $(RM) -r .pytest_cache/ find . -name __pycache__ | xargs -r $(RM) -r @@ -57,3 +58,7 @@ clean: #------------------------------------------------------------------------------ $(BPAN): git clone https://github.com/bpan-org/bpan.git --depth 1 $@ + +$(VENV): + $(PYTHON) -m venv $@ + pip install pytest requests