From 826204b667ba3830199b6e957848121952e63db6 Mon Sep 17 00:00:00 2001 From: justusbunsi Date: Sun, 17 Oct 2021 10:53:54 +0200 Subject: [PATCH] Allow for running dedicated tests Signed-off-by: Steven Kriegler --- Makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2e26473..db21fe7 100644 --- a/Makefile +++ b/Makefile @@ -7,15 +7,17 @@ help: @echo " - build Build the bot" @echo " - run Start the bot" @echo " - clean Delete generated files" - @echo " - test Run test suite" - @echo " - coverage Run test suite and generates coverage report as HTML file" + @echo " - test Run full test suite" + @echo " - test p=./path/to/package Run test suite for specific package" + @echo " - test\#SpecificTestName Run a specific" + @echo " - coverage Run full test suite and generates coverage report as HTML file" @echo " - dep Dependency maintenance (tidy, vendor, verify)" @echo " - vet Examine Go source code and reports suspicious parts" @echo " - fmt Format the Go code" @echo " - help Print this help" build: - GOARCH=amd64 GOOS=linux go build --mod=vendor -o ${BINARY_NAME} ./cmd/gitea-sonarqube-bot/ + GOARCH=amd64 GOOS=linux go build -mod=vendor -o ${BINARY_NAME} ./cmd/gitea-sonarqube-bot/ run: ./${BINARY_NAME} @@ -26,10 +28,17 @@ clean: rm -f cover.out cover.html test: - go test -v ./... +ifdef p + go test -v -mod=vendor $(p) +else + go test -v -mod=vendor ./... +endif + +test\#%: + go test -mod=vendor -run $(subst .,/,$*) ./... coverage: - go test -v -coverprofile=cover.out ./... + go test -coverprofile=cover.out ./... go tool cover -html=cover.out -o cover.html dep: