|
|
@@ -0,0 +1,53 @@
|
|
|
+OMIT=/usr/share/pyshared/*,/usr/local/lib/python*,*__init__.py,test*
|
|
|
+COVERAGE_OUTPUT_DIR=coverage
|
|
|
+TESTS=`find tests -name test_\*.py`
|
|
|
+
|
|
|
+# Find python coverage version
|
|
|
+ifeq ($(findstring python-coverage,$(wildcard /usr/bin/*)), python-coverage)
|
|
|
+COVERAGE=/usr/bin/python-coverage
|
|
|
+else
|
|
|
+COVERAGE=`which coverage`
|
|
|
+endif
|
|
|
+
|
|
|
+all:
|
|
|
+
|
|
|
+# Unit tests
|
|
|
+test:
|
|
|
+ @for t in ${TESTS}; do \
|
|
|
+ python test.py $$t; \
|
|
|
+ done
|
|
|
+
|
|
|
+# Cleanup
|
|
|
+clean:
|
|
|
+ rm -rf .coverage ${COVERAGE_OUTPUT_DIR}
|
|
|
+
|
|
|
+distclean: clean
|
|
|
+ rm -rf `find -name \*.pyc`
|
|
|
+
|
|
|
+# Code coverage (differs between versions)
|
|
|
+coverage: .coverage
|
|
|
+
|
|
|
+ifeq ($(findstring python-coverage,$(wildcard /usr/bin/*)), python-coverage)
|
|
|
+.coverage:
|
|
|
+ @${COVERAGE} erase
|
|
|
+ @rm -f ${COVERAGE_OUTPUT_DIR}/*
|
|
|
+ @mkdir -p ${COVERAGE_OUTPUT_DIR} 2>/dev/null || true
|
|
|
+ @for t in ${TESTS}; do \
|
|
|
+ ${COVERAGE} -x test.py $$t; \
|
|
|
+ ${COVERAGE} combine; \
|
|
|
+ done
|
|
|
+ @${COVERAGE} html --omit=${OMIT} -d ${COVERAGE_OUTPUT_DIR}
|
|
|
+ @rm $@
|
|
|
+ @echo "Coverage report created in ${COVERAGE_OUTPUT_DIR}/index.html"
|
|
|
+else
|
|
|
+.coverage:
|
|
|
+ @mkdir -p ${COVERAGE_OUTPUT_DIR} 2>/dev/null || true
|
|
|
+ @${COVERAGE} erase
|
|
|
+ @for t in ${TESTS}; do \
|
|
|
+ ${COVERAGE} --omit ${OMIT} -x test.py $$t; \
|
|
|
+ ${COVERAGE} --omit ${OMIT} -c; \
|
|
|
+ done
|
|
|
+ @${COVERAGE} html --omit ${OMIT} --dir ${COVERAGE_OUTPUT_DIR}
|
|
|
+ @rm $@
|
|
|
+ @echo "Coverage report created in ${COVERAGE_OUTPUT_DIR}/index.html"
|
|
|
+endif
|