#!/usr/bin/make -f
# -*- makefile -*-

export PYBUILD_NAME=pytest

# 2015-12-16 barry@debian.org: Because pytest does not clean up after itself,
# use a custom temporary directory (which is easier to clean up manually,
# e.g. in an sbuild).
export PYBUILD_BEFORE_TEST=mkdir -p {dir}/debian/tmp/test-working-directory
export PYBUILD_AFTER_TEST=rm -rf {dir}/debian/tmp/test-working-directory
export PYBUILD_TEST_CUSTOM=1
export PYBUILD_TEST_ARGS=cd {dir}/debian/tmp/test-working-directory && \
	{interpreter} -m pytest --lsof -rfsxX \
		--ignore={dir}/testing/test_entry_points.py \
		--ignore={dir}/testing/test_terminal.py \
		-k 'not test_code_highlight' \
		{dir}/testing

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(shell pybuild --print {build_dir} --interpreter python3) \
		SPHINXBUILD=/usr/share/sphinx/scripts/python3/sphinx-build \
		$(MAKE) -C doc/en man html
endif
