-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
55 lines (45 loc) · 1.57 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
# This is to allow for passing additional arguments to the test system.
# For example: make test ci.tests
# These extra arguments need to be ignored by make.
ifeq ($(firstword $(MAKECMDGOALS)),$(filter $(firstword $(MAKECMDGOALS)), test coverage))
# use the rest as arguments
TEST_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(TEST_ARGS):;@:)
endif
CIVET_TEST_JOBS ?= 12
MAX_MISSING_LINES := 80
py_files := $(shell git ls-files '*.py')
all: coverage check
.PHONY: test
test:
python -Werror ./manage.py test --parallel=$(CIVET_TEST_JOBS) $(TEST_ARGS)
.coverage: $(py_files)
@export COVERAGE_PROCESS_START="./.coveragerc"
@printf "import coverage\ncoverage.process_startup()\n" > sitecustomize.py
@export PYTHONWARNINGS="error"
coverage erase
coverage run --parallel-mode --source "." ./manage.py test --parallel=$(CIVET_TEST_JOBS) $(TEST_ARGS)
coverage combine
@rm -f sitecustomize.py
.PHONY: coverage
coverage: .coverage
coverage report -m
htmlcov/index.html: .coverage
coverage html --title='CIVET Coverage' --fail-under=99
.PHONY: htmlcov
htmlcov: htmlcov/index.html
.PHONY: check
check: .coverage
@missing_lines=`coverage report |tail -1 |awk '{printf $$3; }'`; \
if [ $(MAX_MISSING_LINES) -ge $$missing_lines ]; then \
echo "PASSED: Missing lines ($$missing_lines) <= than max $(MAX_MISSING_LINES)"; \
else \
echo "FAILED: More missing lines ($$missing_lines) than the max $(MAX_MISSING_LINES)"; \
exit 1; \
fi
.PHONY: clean
clean:
rm -f .coverage
find . -name '*.pyc' -delete
rm -rf htmlcov