提交 88857f15 编写于 作者: I Ivo De Decker

Add test coverage

Based on patches by Niels Thykier to add coverage to britney.
上级 11fc5069
......@@ -5,3 +5,4 @@ omit =
*/lib/python*/*
*/dist-packages/*
*/tests/*
source = .
......@@ -11,7 +11,10 @@ test stretch:
test buster:
<<: *template
image: debian:buster
script: debian/run-ci
script: debian/run-ci --with-coverage
artifacts:
paths:
- coverage
flake8:
<<: *template
......@@ -28,6 +31,7 @@ pages:
- apt-get install -y python-epydoc
- mkdir -p public/epydoc
- epydoc -q --html --graph all --css blue -n DAK -o public/epydoc --include-log --show-imports dak dakweb
- mv coverage public/coverage
artifacts:
paths:
- public
......
......@@ -11,11 +11,13 @@ Build-Depends: alembic,
postgresql-11-debversion | postgresql-9.6-debversion | postgresql-9.4-debversion,
python-all-dev,
python-apt,
python-coverage,
python-debian,
python-debianbts,
python-ldap,
python-psycopg2,
python-pytest,
python-pytest-cov,
python-rrdtool,
python-sqlalchemy,
python-tabulate,
......
......@@ -7,6 +7,10 @@ ifneq ($(JENKINS_EXPORTS_DIR),)
PYBUILD_EXTRA_ARGS = --junit-xml=$(JENKINS_EXPORTS_DIR)/test-results/tests.xml
endif
ifeq ($(RUN_COVERAGE),y)
PYTEST_COV_OPTIONS = --cov-branch --cov --cov-report=
endif
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq ($(JENKINS_EXPORTS_DIR),)
......@@ -14,8 +18,18 @@ ifneq ($(JENKINS_EXPORTS_DIR),)
endif
mkdir -p debian/test-gnupghome
make -C tests/fixtures/packages
GNUPGHOME=$$(pwd)/debian/test-gnupghome py.test -v daklib tests $(PYBUILD_EXTRA_ARGS)
GNUPGHOME=$$(pwd)/debian/test-gnupghome py.test -v $(PYTEST_COV_OPTIONS) daklib tests $(PYBUILD_EXTRA_ARGS)
ifeq ($(RUN_COVERAGE),y)
python-coverage combine --append
endif
./integration-tests/run-tests
ifeq ($(RUN_COVERAGE),y)
python-coverage combine --append
python-coverage report -m
echo
python-coverage html -d coverage
endif
endif
# Replace with "debian/test-gnupghome/" in d/clean once
......
......@@ -16,6 +16,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
if [ "x$1" = "x--with-coverage" ]; then
RUN_COVERAGE=y
else
RUN_COVERAGE=
fi
export RUN_COVERAGE
set -eu
if [ ! -f dak/dak.py ]; then
......
#!/bin/bash
# wrapper to collect coverage info when running dak
if [ "$RUN_COVERAGE" = "y" ]
then
exec python-coverage run --rcfile "${DAK_ROOT}/.coveragerc" --parallel-mode "${DAK_ROOT}/dak/dak.py" "$@"
else
exec "${DAK_ROOT}/dak/dak.py" "$@"
fi
......@@ -75,7 +75,12 @@ dak-setup() {
(cd ${setupdir}; ./init_minimal_conf | $USER_CMD tee ${DAK_CONFIG} >/dev/null)
$USER_CMD echo 'DB::Role "dak";' | tee -a ${DAK_CONFIG} >/dev/null
ln -s ${DAK_ROOT}/dak/dak.py ${DAKBASE}/bin/dak
if [[ ! -v DAK_INTEGRATION_TEST ]]; then
ln -s ${DAK_ROOT}/dak/dak.py ${DAKBASE}/bin/dak
else
# wrapper to collect coverage information
ln -s ${DAK_ROOT}/integration-tests/dak-coverage.sh ${DAKBASE}/bin/dak
fi
# Update the database schema
$USER_CMD ${DAK_ROOT}/dak/dak.py update-db --yes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册