Add helper functions to set up config file fixtures.
[dput.git] / Makefile
blob52f9fee6bccb15082ea534876d091c9312d30401
1 #! /usr/bin/make -f
3 PYTHON ?= /usr/bin/python2
5 UNITTEST2 = /usr/bin/unit2
7 PY_MODULE_SUFFIX = .py
8 PY_MODULE_BYTECODE_SUFFIX = .pyc
9 package_modules = $(shell find ${CURDIR}/dput/ -name '*${PY_MODULE_SUFFIX}')
10 python_modules = $(shell find ${CURDIR}/ -name '*${PY_MODULE_SUFFIX}')
12 GENERATED_FILES :=
13 GENERATED_FILES += $(patsubst \
14 %${PY_MODULE_SUFFIX},%${PY_MODULE_BYTECODE_SUFFIX}, \
15 ${python_modules})
17 UNITTEST_OPTS ?= --buffer
19 PYTHON_COVERAGE = $(PYTHON) -m coverage
20 COVERAGE_RUN_OPTS ?= --branch
21 COVERAGE_REPORT_OPTS ?=
22 COVERAGE_TEXT_REPORT_OPTS ?=
23 COVERAGE_HTML_REPORT_OPTS ?=
26 .PHONY: all
27 all:
30 .PHONY: clean
31 clean:
32 $(RM) -r ${GENERATED_FILES}
35 .PHONY: tags
36 tags: TAGS
38 GENERATED_FILES += TAGS
40 TAGS: ${python_modules}
41 etags --output "$@" --lang=python ${python_modules}
44 .PHONY: test
45 test: test-unittest test-coverage
47 .PHONY: test-unittest
48 test-unittest:
49 $(PYTHON) -m unittest discover ${UNITTEST_OPTS}
51 .PHONY: test-coverage
52 test-coverage: test-coverage-run test-coverage-html test-coverage-report
54 GENERATED_FILES += .coverage
56 .PHONY: test-coverage-run
57 test-coverage-run: coverage_opts = ${COVERAGE_RUN_OPTS}
58 test-coverage-run:
59 $(PYTHON) -m coverage run ${coverage_opts} \
60 $(UNITTEST2) discover ${UNITTEST_OPTS}
62 GENERATED_FILES += htmlcov/
64 .PHONY: test-coverage-html
65 test-coverage-html: coverage_opts = ${COVERAGE_REPORT_OPTS} ${COVERAGE_HTML_REPORT_OPTS}
66 test-coverage-html:
67 $(PYTHON_COVERAGE) html ${coverage_opts} ${package_modules}
69 .PHONY: test-coverage-report
70 test-coverage-report: coverage_opts = ${COVERAGE_REPORT_OPTS} ${COVERAGE_TEXT_REPORT_OPTS}
71 test-coverage-report:
72 $(PYTHON_COVERAGE) report ${coverage_opts} ${package_modules}
75 # Local variables:
76 # coding: utf-8
77 # mode: make
78 # End:
79 # vim: fileencoding=utf-8 filetype=make :