Skip to content

Commit 0df634b

Browse files
committed
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.
1 parent 3ffb566 commit 0df634b

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.bpan/
2+
/.venv/
23
/tests/__pycache__/
34
/__pycache__/

.setup.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ SHELL := bash
66
define run-with
77
$(if $(shell command -v $1), \
88
$3, \
9-
$(warning WARNING: Can't 'make $2'. No '$1' command found.))
9+
$(error ERROR: Can't 'make $2'. No '$1' command found.))
1010
endef
1111

1212
ifeq (,$(shell git diff --stat))
1313
GIT_STATUS_IS_CLEAN := 1
1414
endif
15+
16+
PYTHON := $(shell command -v python3 || command -v python)
17+
ifeq (,$(and $(PYTHON),$(findstring Python 3.,$(shell $(PYTHON) --version))))
18+
$(error Python 3 not installed for testing)
19+
endif

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ endif
88
endif
99

1010
BPAN := .bpan
11+
VENV := .venv
1112

13+
export PATH := .venv/bin:$(PATH)
1214

1315
#------------------------------------------------------------------------------
1416
# User targets
@@ -23,9 +25,8 @@ test-bash: $(BPAN)
2325
$(call run-with,prove,$@,\
2426
prove -r $(if $v,-v )$(test))
2527

26-
test-python:
27-
$(call run-with,py.test,$@,\
28-
py.test tests)
28+
test-python: $(VENV)
29+
py.test tests
2930

3031
test-online:
3132
dry_run=1 bash -x ./openqa-label-known-issues-multi < ./tests/incompletes
@@ -48,7 +49,7 @@ update-deps:
4849

4950
clean:
5051
$(RM) job_post_response
51-
$(RM) -r $(BPAN)
52+
$(RM) -r $(BPAN) $(VENV)
5253
$(RM) -r .pytest_cache/
5354
find . -name __pycache__ | xargs -r $(RM) -r
5455

@@ -57,3 +58,7 @@ clean:
5758
#------------------------------------------------------------------------------
5859
$(BPAN):
5960
git clone https://github.com/bpan-org/bpan.git --depth 1 $@
61+
62+
$(VENV):
63+
$(PYTHON) -m venv $@
64+
pip install pytest requests

0 commit comments

Comments
 (0)