File: test.mk

package info (click to toggle)
dput 1.2.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 38,396 kB
  • sloc: python: 13,102; sh: 162; makefile: 42
file content (89 lines) | stat: -rw-r--r-- 2,719 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# test.mk
# Part of ‘dput’, a Debian package upload toolkit.
#
# This is free software, and you are welcome to redistribute it under
# certain conditions; see the end of this file for copyright
# information, grant of license, and disclaimer of warranty.

# Makefile rules for test suite.

MODULE_DIR := $(CURDIR)

TEST_MODULES += $(shell find ${MODULE_DIR}/ -name 'test_*.py')

PYTHON_UNITTEST = $(PYTHON) ${PYTHON_OPTS} -m unittest
UNITTEST_NAMES ?= discover
UNITTEST_OPTS ?= ${UNITTEST_NAMES} --buffer

export COVERAGE_DIR = ${MODULE_DIR}/.coverage
coverage_html_report_dir = ${MODULE_DIR}/htmlcov

PYTHON_COVERAGE = $(PYTHON) ${PYTHON_OPTS} -m coverage
COVERAGE_RUN_OPTS ?= --branch
COVERAGE_REPORT_OPTS ?=
COVERAGE_TEXT_REPORT_OPTS ?=
COVERAGE_HTML_REPORT_OPTS ?=


.PHONY: test
test: test-unittest test-manpages

.PHONY: test-unittest
test-unittest:
	$(PYTHON_UNITTEST) ${UNITTEST_OPTS}

.PHONY: test-coverage
test-coverage: test-coverage-run test-coverage-html test-coverage-report

.PHONY: test-coverage-run
test-coverage-run: coverage_opts = ${COVERAGE_RUN_OPTS}
test-coverage-run: ${CODE_MODULES}
	$(PYTHON_COVERAGE) run ${coverage_opts} \
		-m unittest ${UNITTEST_OPTS}

${COVERAGE_DIR}: test-coverage-run

GENERATED_FILES += ${COVERAGE_DIR}

.PHONY: test-coverage-html
test-coverage-html: coverage_opts = ${COVERAGE_REPORT_OPTS} ${COVERAGE_HTML_REPORT_OPTS}
test-coverage-html: ${COVERAGE_DIR}
	$(PYTHON_COVERAGE) html ${coverage_opts} \
		--directory ${coverage_html_report_dir}/ \
		$(filter-out ${TEST_MODULES},${package_modules})

GENERATED_FILES += ${coverage_html_report_dir}

.PHONY: test-coverage-report
test-coverage-report: coverage_opts = ${COVERAGE_REPORT_OPTS} ${COVERAGE_TEXT_REPORT_OPTS}
test-coverage-report: .coverage
	$(PYTHON_COVERAGE) report ${coverage_opts} \
		$(filter-out ${TEST_MODULES},${package_modules})


.PHONY: test-manpages
test-manpages: export LC_ALL = C.UTF-8
test-manpages: export MANROFFSEQ =
test-manpages: export MANWIDTH = 80
test-manpages: export MANOPTS = --encoding=UTF-8 --troff-device=utf8 --ditroff
test-manpages: ${manpage_paths}
	for manfile in $^ ; do \
		printf "Rendering %s:" $$manfile ; \
		man --local-file --warnings $$manfile > /dev/null ; \
		printf " done.\n" ; \
	done


# Copyright © 2008–2024 Ben Finney <bignose@debian.org>
#
# This is free software: you may copy, modify, and/or distribute this work
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3 of that license or any later version.
# No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.


# Local Variables:
# coding: utf-8
# mode: makefile
# End:
# vim: fileencoding=utf-8 filetype=make :