#!/usr/bin/make -f
#
# Univention UCS test
#  rules file for the debian package
#
# Copyright 2013-2021 Univention GmbH
#
# https://www.univention.de/
#
# All rights reserved.
#
# The source code of this program is made available
# under the terms of the GNU Affero General Public License version 3
# (GNU AGPL V3) as published by the Free Software Foundation.
#
# Binary versions of this program provided by Univention to you as
# well as other copyrighted, protected or trademarked materials like
# Logos, graphics, fonts, specific documentations and configurations,
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <https://www.gnu.org/licenses/>.

PACKAGES := $(shell sed -rne '/^Provides:/,/^\S/{/\sucs-test-module(\s|,|$$)/{g;p}};s/Package: //;T;h' debian/control)
BLANK :=
SPACE := $(BLANK) $(BLANK)
COMMA := ,

%:
	dh $@ --with python2,python3,univention-l10n,umc

override_dh_install:
	dh_install --sourcedir=$(CURDIR) -Xde.po
	touch debian/ucs-test-udm/usr/lib/python2.7/dist-packages/univention/admin/handlers/tests/__init__.py
	touch debian/ucs-test-udm/usr/lib/python3/dist-packages/univention/admin/handlers/tests/__init__.py

override_dh_auto_test:
	./lint
	python3 -m univention.testing.data -v
	python3 -m univention.testing.errors -v
	python3 -m univention.testing.format.html -v
	python3 -m univention.testing.format.jenkins -v
	python3 -m univention.testing.format.junit -v
	python3 -m univention.testing.format.tap -v
	python3 -m univention.testing.format.text -v
	python3 -m univention.testing.internal -v
	python3 -m univention.testing.udm -v
	python3 -m univention.testing.utils -v
	unittest/run-tests.sh

override_dh_gencontrol:
	dh_gencontrol -- -Vucs-test:all-packages=$(subst $(SPACE),$(COMMA),$(PACKAGES))

override_dh_auto_clean:
	find -name '*.pyc' -delete
	dh_auto_clean
