#!/usr/bin/make -f

# Tests that fetch GGUF models over the network. Each opens a model from
# huggingface.co, modelscope.cn or an Ollama registry, so none can run in a
# build chroot. Upstream does not gate them on testing.Short(), so they have to
# be named. Everything else still runs, including the overflow and
# DoS-hardening tests, which use local fixtures.
#
# Keep this on one line: a make line continuation would insert a space after
# each "|" and the alternatives would then never match.
SKIP_NET = TestGGUFFile_Architecture|TestGGUFFile_EstimateLLaMACppRun|TestGGUFFile_EstimateStableDiffusionRun|TestGGUFFile_extractFileType|TestGGUFFile_Metadata|TestParseGGUFFileRemote|TestParseGGUFFileFromHuggingFace$$|TestParseGGUFFileFromHuggingFace_ZeroLengthTensorDimension|TestParseGGUFFileFromModelScope|TestParseGGUFFileFromOllama|TestGGUFFile_Tokenizer

%:
	dh $@ --builddirectory=debian/_build --buildsystem=golang --with=golang

override_dh_auto_test:
	dh_auto_test -- -skip '$(SKIP_NET)'

execute_after_dh_auto_install:
	# cmd/gguf-parser is upstream's command line tool as a nested Go module, and
	# this package is the library. A module-aware go list only enumerates the
	# main module, so it is neither built nor tested here, and its own go.mod
	# requires urfave/cli/v2, jedib0t/go-pretty/v6 and go-md2man, none of which
	# this package build-depends on. Shipping it would put an untested module
	# with unsatisfiable requirements into the import path.
	rm -rf debian/golang-github-gpustack-gguf-parser-go-dev/usr/share/gocode/src/github.com/gpustack/gguf-parser-go/cmd
