#!/usr/bin/make -f

%:
	dh $@ --builddirectory=_build --buildsystem=golang

# Patch testscript/testscript.go and override dh-golang default GOPROXY=off
# to allow TestScripts/env_var_with_go and TestSimple/cover to PASS.
# dh-golang (>= 1.66) replaces an empty GOPROXY with "off", so the value has
# to be set explicitly. Only env_var_with_go gets it: it merely prints GOPROXY
# and never fetches anything, whereas cover must stay offline.
SKIP1:=TestSimple/cover|TestScripts/env_var_with_go
# TestSetup/overlay/overlay: requires Internet
# TestScripts/pty: flaky test FTBFS https://bugs.debian.org/1119927
SKIP2:=TestSetup/overlay/overlay|TestScripts/pty
override_dh_auto_test:
	-dh_auto_test $(DH_BUILD_OPTS) -- -run="$(SKIP1)|$(SKIP2)"
	patch -N -p1 -i debian/0001-Allow-TestSimple-cover-to-PASS.patch
	dh_auto_test $(DH_BUILD_OPTS) -- -run="TestSimple/cover"
	GOPROXY=https://proxy.golang.org,direct dh_auto_test $(DH_BUILD_OPTS) -- -run="TestScripts/env_var_with_go"
	patch -R -p1 -i debian/0001-Allow-TestSimple-cover-to-PASS.patch
	rm -fv _build/src/github.com/rogpeppe/go-internal/testscript/testscript.go.orig
	dh_auto_test $(DH_BUILD_OPTS) -- -skip="$(SKIP1)|$(SKIP2)"
