-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
58 lines (47 loc) · 1.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Makefile
#
# Copyright (C) 2017 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPLv2
#
# Standard interface to work with the project.
# Run tests, excluding these tagged items, e.g
# make check OMITTED_TAGS="tag1 tag2"
OMITTED_TAGS =
empty:=
space:= $(empty) $(empty)
REPORT_DIR = reports
COVERAGE_REPORT_DIR = $(REPORT_DIR)/coverage
TESTS_REPORT_DIR = $(REPORT_DIR)/tests
# Elaborate mechanism just to get the correct syntax for the pytest markers param
_FIRST_TAG := $(firstword $(OMITTED_TAGS))
PYTEST_TAGS_EXPR := $(foreach tag, $(OMITTED_TAGS), $(if $(filter $(tag), $(_FIRST_TAG)),not $(tag),and not $(tag)))
ifeq ($(PYTEST_TAGS_EXPR), )
PYTEST_TAGS_FLAG :=
else
PYTEST_TAGS_FLAG := -m "$(strip $(PYTEST_TAGS_EXPR))"
endif
BEHAVE_TAGS_FLAG := $(join $(addprefix --tags=-,$(OMITTED_TAGS)), $(space))
#
# Run the tests
#
# Requirements:
# - pytest
# - behave
# - pytest-cov
# - pytest-tap
#
check:
# Refresh the reports directory
rm -rf $(REPORT_DIR)
mkdir -p $(REPORT_DIR)
mkdir -p $(COVERAGE_REPORT_DIR)
mkdir -p $(TESTS_REPORT_DIR)
# Run the tests
-coverage run --module pytest $(PYTEST_TAGS_FLAG) --junitxml=$(TESTS_REPORT_DIR)/pytest_results.xml
-coverage run --append --module behave $(BEHAVE_TAGS_FLAG) --junit --junit-directory=$(TESTS_REPORT_DIR)
# Generate reports
coverage xml
coverage html
coverage-badge -o $(COVERAGE_REPORT_DIR)/kano-settings-coverage.svg
test: check
.PHONY: check test