#!/usr/bin/make -f

# Do not build the qingstor and mega backends for now, the required
# go packages are not available yet.
export DH_GOLANG_EXCLUDES := backend/qingstor backend/mega

# Also install test data
export DH_GOLANG_INSTALL_EXTRA := \
	backend/alias/test \
	backend/drive/test \
	backend/http/test \
	cmd/lsf/testfiles \
	cmd/tree/testfiles

export BUILDTESTDIR=$(CURDIR)/buildtest

# some arches need more than 10 min to run TestTestsToRegexpLive
ARCHES_SLOW_TEST := mips64el mipsel
ifneq ($(findstring $(DEB_BUILD_ARCH),$(ARCHES_SLOW_TEST)),)
  EXTRA_TESTFLAGS := -timeout 20m
endif

%:
	dh $@ --buildsystem=golang --with=golang,bash-completion

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(BUILDTESTDIR)

# build-time tests for github.com/ncw/rclone/vfs access the config file
# so provide a null config
override_dh_auto_test:
	export XDG_CONFIG_HOME=$(BUILDTESTDIR); \
	export  XDG_CACHE_HOME=$(BUILDTESTDIR); \
	dh_auto_test -- $(EXTRA_TESTFLAGS)
