#!/usr/bin/make -f

%:
	dh $@

ifneq ($(JENKINS_EXPORTS_DIR),)
PYBUILD_EXTRA_ARGS = --junit-xml=$(JENKINS_EXPORTS_DIR)/test-results/tests.xml
endif

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq ($(JENKINS_EXPORTS_DIR),)
	mkdir -pv $(JENKINS_EXPORTS_DIR)/test-results
endif
	mkdir -p debian/test-gnupghome
	make -C tests/fixtures/packages
	GNUPGHOME=$$(pwd)/debian/test-gnupghome py.test -v daklib tests $(PYBUILD_EXTRA_ARGS)
	./integration-tests/run-tests
endif

# Replace with "debian/test-gnupghome/" in d/clean once
# debhelper (>= 9.20151116) can be used for dak
override_dh_auto_clean:
	make -C tests/fixtures/packages clean
	rm -fr debian/test-gnupghome
	dh_auto_clean
