2023-12-25 08:56:48 +00:00
# Inspired from https://dustinspecker.com/posts/go-combined-unit-integration-code-coverage/ and https://netdevops.me/2023/test-coverage-for-go-integration-tests/
BIN_DIR = $( CURDIR) /bin
COVERAGE_DIR = $( CURDIR) /coverage
BINARY = $( BIN_DIR) /gosimplenpm
.PHONY : clean
2023-06-11 00:32:02 +00:00
clean :
go clean
2023-12-25 08:56:48 +00:00
.PHONY : dep
2023-06-11 00:32:02 +00:00
dep :
go mod tidy
2023-12-25 08:56:48 +00:00
.PHONY : fmt
2023-06-11 00:32:02 +00:00
fmt :
go fmt ./...
2023-12-25 08:56:48 +00:00
.PHONY : lint
2023-06-11 00:32:02 +00:00
lint :
golangci-lint run
2023-12-25 08:56:48 +00:00
coverage-unit :
go test ./... -short -covermode= count -coverprofile= ./coverage/unit.out
go tool cover -func= ./coverage/unit.out
coverage-integration :
go test ./... -run Integration -covermode= count -coverprofile= ./coverage/integration.out
go tool cover -func= ./coverage/integration.out
.PHONY : build -debug
build-debug :
mkdir -p $( BIN_DIR)
go build -o $( BINARY) -cover main.go
.PHONY : test
test : build -debug
rm -rf $( COVERAGE_DIR)
mkdir -p $( COVERAGE_DIR)
go test -cover ./... -args -test.gocoverdir= " $( COVERAGE_DIR) "
.PHONY : coverage -full
coverage-full : test
go tool covdata textfmt -i= $( COVERAGE_DIR) -o $( COVERAGE_DIR) /coverage.out
go tool cover -func= $( COVERAGE_DIR) /coverage.out
.PHONY : coverage -html
coverage-html :
go tool cover -html= ./coverage/coverage.out -o ./coverage/coverage.html
open ./coverage/coverage.html
.PHONY : lint -all
2023-06-11 00:32:02 +00:00
lint-all :
golangci-lint run --enable-all