SHELL := /bin/bash
export PATH := $(CURDIR)/_tools/bin:$(PATH)

GOPKGS := ./example ./example2

# use this if you have an explicit list of go packages that you want to run tests for
# this creates a dummy_test.go file with just the package name in all your go packages
# so that all packages contribute to code-coverage
prep_coverage_1:
	$(foreach dir,$(GOPKGS),\
		echo "package $(subst ./,,$(dir))" > $(dir)/just_an_empty_test.go;)

# use this if you want to scan for go packages that you want to run tests for
# this creates a dummy_test.go file with just the package name in all your go packages
# so that all packages contribute to code-coverage
prep_coverage_2:
	./prep_coverage.sh

# this generates code-coverage report
# if you do not run any prep_coverage before it, packages that have no tests won't get included in coverage report
# this will lead to incorrect overall coverage
coverage:
    go test --race ./... -coverprofile=coverage.txt -covermode=atomic

coverage_with_prep: prep_coverage_2 coverage
