rules.mk 789 B

1234567891011121314151617181920212223242526272829
  1. TESTS=$(wildcard tests/test_*.py)
  2. COVERAGE_OUTPUT_DIR := coverage
  3. OMIT := --omit /usr/share/pyshared/*,/usr/lib64/portage/*
  4. ifeq ($(findstring python-coverage,$(wildcard /usr/bin/*)), python-coverage)
  5. COVERAGE=/usr/bin/python-coverage
  6. else
  7. COVERAGE=/usr/bin/coverage
  8. endif
  9. .PHONY: test coverage $(TESTS)
  10. test: $(TESTS) build
  11. coverage: ${COVERAGE}
  12. mkdir ${COVERAGE_OUTPUT_DIR} 2>/dev/null || true
  13. ${COVERAGE} erase
  14. for t in ${TESTS}; do \
  15. echo $$t; \
  16. ${COVERAGE} ${OMIT} -x test.py $$t; \
  17. ${COVERAGE} ${OMIT} -c; \
  18. done
  19. ${COVERAGE} html ${OMIT} --dir ${COVERAGE_OUTPUT_DIR}
  20. ${COVERAGE}:
  21. @echo "Install package 'python-coverage' to generate a coverage report."
  22. @echo "On Debian/Ubuntu use: sudo apt-get install python-coverage"; false
  23. $(TESTS): ; @python -m testrunner $@