Skip to content

Commit 237758b

Browse files
authored
Make test output less verbose (#713)
1 parent d6aaadc commit 237758b

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

Makefile

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help build test test-unit test-integration test-endpoints test-publish test-all lint lint-fix validate validate-schemas validate-examples check dev-compose clean publisher generate-schema check-schema
1+
.PHONY: help build test test-unit test-unit-verbose test-integration test-endpoints test-publish test-all lint lint-fix validate validate-schemas validate-examples check dev-compose clean publisher generate-schema check-schema
22

33
# Default target
44
help: ## Show this help message
@@ -28,15 +28,36 @@ check-schema: ## Check if server.schema.json is in sync with openapi.yaml
2828
# Test targets
2929
test-unit: ## Run unit tests with coverage (requires PostgreSQL)
3030
@echo "Starting PostgreSQL for unit tests..."
31-
@docker compose up -d postgres
31+
@docker compose up -d postgres 2>&1 | grep -v "Pulling\|Pulled\|Creating\|Created\|Starting\|Started" || true
3232
@echo "Waiting for PostgreSQL to be ready..."
3333
@sleep 3
34+
@echo ""
3435
@echo "Running unit tests..."
35-
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/...
36-
go tool cover -html=coverage.out -o coverage.html
37-
@echo "Coverage report generated: coverage.html"
38-
@echo "Stopping PostgreSQL..."
39-
@docker compose down postgres
36+
@if command -v gotestsum >/dev/null 2>&1; then \
37+
gotestsum --format pkgname-and-test-fails -- -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/... 2>&1 | grep -v "ld: warning:"; \
38+
else \
39+
go test -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/... 2>&1 | grep -v "ld: warning:" | grep -v "^ld:"; \
40+
fi
41+
@echo ""
42+
@go tool cover -html=coverage.out -o coverage.html
43+
@echo "✅ Coverage report: coverage.html"
44+
@go tool cover -func=coverage.out | tail -1
45+
@echo ""
46+
@docker compose down postgres >/dev/null 2>&1
47+
@echo "✅ Tests complete"
48+
49+
test-unit-verbose: ## Run unit tests with verbose output
50+
@echo "Starting PostgreSQL for unit tests..."
51+
@docker compose up -d postgres 2>&1 | grep -v "Pulling\|Pulled\|Creating\|Created\|Starting\|Started" || true
52+
@echo "Waiting for PostgreSQL to be ready..."
53+
@sleep 3
54+
@echo ""
55+
@echo "Running unit tests (verbose)..."
56+
@go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/... 2>&1 | grep -v "ld: warning:" | grep -v "^ld:"
57+
@echo ""
58+
@go tool cover -html=coverage.out -o coverage.html
59+
@echo "✅ Coverage report: coverage.html"
60+
@docker compose down postgres >/dev/null 2>&1
4061

4162
test: ## Run unit tests (use 'make test-all' to run all tests)
4263
@echo "⚠️ Running unit tests only. Use 'make test-all' to run both unit and integration tests."

0 commit comments

Comments
 (0)