-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
107 lines (92 loc) · 2.69 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Makefile for fastmap Package Testing
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOMOD=$(GOCMD) mod
GOCLEAN=$(GOCMD) clean
GOVENDOR=$(GOCMD) mod vendor
# Project parameters
PACKAGE=github.com/billowdev/fastmap
TEST_PACKAGE=./...
# Colors for output
GREEN=\033[0;32m
YELLOW=\033[0;33m
NC=\033[0m
# Default target
.PHONY: all
all: test coverage
# Initialize dependencies
.PHONY: init
init:
@echo "$(YELLOW)Initializing dependencies...$(NC)"
$(GOMOD) tidy
$(GOMOD) download
# Run all tests
.PHONY: test
test:
@echo "$(YELLOW)Running all tests...$(NC)"
$(GOTEST) $(TEST_PACKAGE)
# Run tests with verbose output
.PHONY: test-verbose
test-verbose:
@echo "$(YELLOW)Running tests with verbose output...$(NC)"
$(GOTEST) -v $(TEST_PACKAGE)
# Generate coverage report
.PHONY: coverage
coverage:
@echo "$(YELLOW)Generating test coverage report...$(NC)"
$(GOTEST) -cover $(TEST_PACKAGE)
$(GOTEST) -coverprofile=coverage.out $(TEST_PACKAGE)
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "$(GREEN)Coverage report generated at coverage.html$(NC)"
# Run specific test
.PHONY: test-specific
test-specific:
@read -p "Enter test name to run (e.g., TestHashMap_Put): " TEST_NAME; \
$(GOTEST) -v -run $$TEST_NAME $(TEST_PACKAGE)
# Run benchmarks
.PHONY: benchmark
benchmark:
@echo "$(YELLOW)Running benchmarks...$(NC)"
$(GOTEST) -bench=. $(TEST_PACKAGE)
# Memory profiling
.PHONY: profile-memory
profile-memory:
@echo "$(YELLOW)Running memory profiling...$(NC)"
$(GOTEST) -bench=. -memprofile=mem.prof $(TEST_PACKAGE)
go tool pprof mem.prof
# CPU profiling
.PHONY: profile-cpu
profile-cpu:
@echo "$(YELLOW)Running CPU profiling...$(NC)"
$(GOTEST) -bench=. -cpuprofile=cpu.prof $(TEST_PACKAGE)
go tool pprof cpu.prof
# Race condition detection
.PHONY: race
race:
@echo "$(YELLOW)Running race condition tests...$(NC)"
$(GOTEST) -race $(TEST_PACKAGE)
# Clean test artifacts
.PHONY: clean
clean:
@echo "$(YELLOW)Cleaning test artifacts...$(NC)"
$(GOCLEAN)
rm -f coverage.out coverage.html
rm -f *.prof
# Help target
.PHONY: help
help:
@echo "Available targets:"
@echo " all - Run tests and generate coverage report"
@echo " init - Initialize dependencies"
@echo " test - Run all tests"
@echo " test-verbose - Run tests with verbose output"
@echo " coverage - Generate test coverage report"
@echo " test-specific - Run a specific test by name"
@echo " benchmark - Run performance benchmarks"
@echo " profile-memory- Generate memory profiling"
@echo " profile-cpu - Generate CPU profiling"
@echo " race - Run race condition tests"
@echo " clean - Clean test artifacts"
@echo " help - Show this help message"