Skip to content

Commit

Permalink
Change run-with function to error instead of warn
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ingydotnet committed Jan 30, 2023
1 parent f9e34bf commit 31022d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.bpan/
/.venv/
/tests/__pycache__/
/__pycache__/
7 changes: 6 additions & 1 deletion .setup.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ endif
endif

BPAN := .bpan
VENV := .venv

export PATH := .venv/bin:$(PATH)

#------------------------------------------------------------------------------
# User targets
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

0 comments on commit 31022d7

Please sign in to comment.