#!/usr/bin/make -f

SKIP_TESTS = $(shell cat debian/tests/pkg-perl/smoke-skip)
TEST_FILES = $(filter-out $(SKIP_TESTS), $(wildcard t/*.t))

%:
	dh $@

override_dh_auto_test:
	RES_OPTIONS=attempts:0 http_proxy= dh_auto_test -- TEST_FILES="$(TEST_FILES)"

execute_after_dh_install:
	find /usr/share/openapi-specification/schemas -name schema.json \
		| while read SCHEMA; \
		  do jq '.["id"]' $${SCHEMA} | tr -d '"' \
			| perl -pe 's/#?\n$$//' | md5sum | cut -d ' ' -f 1 \
			| xargs -i ln -s $${SCHEMA} debian/libjson-validator-perl/usr/share/perl5/JSON/Validator/cache/{}; \
		  done