.PHONY: devp/test-go
devp/test-go:
	@# Test all
	$(Q) go test -race ./...

.PHONY: devp/coverage/deps
devp/coverage/deps: ${DEVP_DEVPTOOL_EXE} ${DEVP_GOTESTSUM_EXE} ${DEVP_GOCOVER_COBERTURA_EXE}
	@# helper target for coverage reports

DEVP_COVERAGE_CMD := ${DEVP_DEVPTOOL_EXE} golang coverage --gotestsum-exe=${DEVP_GOTESTSUM_EXE} --gocover-cobertura-exe=${DEVP_GOCOVER_COBERTURA_EXE} --default-junit-path=${DEVP_JUNIT} --default-cobertura-path=${DEVP_COBERTURA} --devp-build-path=${DEVP_BUILD}/coverage

.PHONY: devp/coverage
devp/coverage: devp/coverage/deps
	@# Test all with coverage reports
	$(Q) ${DEVP_COVERAGE_CMD} --detailed=false
	$(Q) echo "For more detailed report run 'make devp/coverage/detailed' or look at test reports in artifacts"

.PHONY: devp/coverage/detailed
devp/coverage/detailed: devp/coverage/deps
	@# Test all with detailed coverage reports
	$(Q) ${DEVP_COVERAGE_CMD}

# To be used for golden tests
.PHONY: devp/test-go/update
devp/test-go/update:
	@# Update golden files
	$(Q) go list -f '{{.XTestImports}}{{.TestImports}}{{.Dir}}' ./... | grep 'git.mws-team.ru/mws/devp/platform-go/pkg/golden' | awk -F ']' '{print $$3}' | xargs -I {} go test {} -update
