-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
244 lines (226 loc) · 7.02 KB
/
Makefile
File metadata and controls
244 lines (226 loc) · 7.02 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# CC Streamer Makefile
# Build, test, and run the CC Streamer application
# Variables
ZIG = zig
BINARY = ./zig-out/bin/ccstreamer
# Colors for output (disabled if NO_COLOR is set)
ifndef NO_COLOR
RED = \033[0;31m
GREEN = \033[0;32m
YELLOW = \033[1;33m
NC = \033[0m # No Color
else
RED =
GREEN =
YELLOW =
NC =
endif
# Default target
.PHONY: all
all: build
# Lint the project
.PHONY: lint
lint:
@echo "Formatting source code..."
@$(ZIG) fmt src/
@$(ZIG) fmt test/
@$(ZIG) fmt build.zig
# Build the project
.PHONY: build
build:
@echo "Formatting source code..."
@$(ZIG) fmt src/
@$(ZIG) fmt test/
@$(ZIG) fmt build.zig
@echo "Building CC Streamer..."
@$(ZIG) build
# Build in release mode
.PHONY: release
release:
@echo "Building CC Streamer (release mode)..."
@$(ZIG) build --release=fast
# Run the application
.PHONY: run
run:
@echo "Formatting source code..."
@$(ZIG) fmt src/
@$(MAKE) build
@$(BINARY)
# Run with arguments
.PHONY: run-args
run-args: build
@$(ZIG) build run -- $(ARGS)
# Run unit tests
.PHONY: test
test:
@echo "Running unit tests..."
@$(ZIG) build test
# Run the basic test runner (from test_runner.sh)
.PHONY: test-basic
test-basic: build
@echo "=== CC Streamer Test Runner ==="
@echo "Testing current implementation status..."
@echo ""
@echo "1. Build status:"
@echo "$(GREEN)✅ Build successful$(NC)"
@echo ""
@echo "2. Running unit tests..."
@if $(ZIG) build test 2>&1; then \
echo "$(GREEN)✅ Unit tests passed$(NC)"; \
else \
echo "$(RED)❌ Unit tests failed$(NC)"; \
fi
@echo ""
@echo "3. Testing basic functionality..."
@mkdir -p tmp
@if echo '{"test": "value"}' | $(BINARY) > tmp/test_output.txt 2>&1; then \
echo "$(GREEN)✅ Basic execution successful$(NC)"; \
echo "Output:"; \
cat tmp/test_output.txt; \
else \
echo "$(RED)❌ Basic execution failed$(NC)"; \
cat tmp/test_output.txt; \
fi
@echo ""
@echo "=== Test complete ==="
# Run manual tests (from test_manual.sh)
.PHONY: test-manual
test-manual: build
@echo "Testing ccstreamer functionality..."
@echo ""
@echo "Test 1: Basic JSON"
@echo '{"type": "test", "value": 42}' | $(BINARY)
@echo ""
@echo "Test 2: NO_COLOR environment variable"
@NO_COLOR=1 echo '{"name": "example"}' | $(BINARY)
@echo ""
@echo "Test 3: Multiple JSON objects"
@echo -e '{"first": true}\n{"second": false}' | $(BINARY)
@echo ""
@echo "Test 4: Malformed JSON (should produce error)"
@echo '{"malformed":' | $(BINARY) 2>&1 || echo "Error handled correctly"
@echo ""
@echo "All manual tests completed."
# Run comprehensive real tests (from run_real_tests.sh)
.PHONY: test-real
test-real: build
@echo "=== CC Streamer Real Test Assessment ==="
@echo "Running comprehensive test validation..."
@echo ""
@E2E_PASS=0; TOKENIZER_PASS=0; PARSER_PASS=0; COLORS_PASS=0; FORMATTER_PASS=0; BINARY_PASS=0; NO_COLOR_PASS=0; \
echo "1. Running E2E Tests:"; \
if $(ZIG) test test/e2e_tests.zig 2>/dev/null; then \
echo "$(GREEN)✅ E2E Tests: PASSING$(NC)"; \
E2E_PASS=1; \
else \
echo "$(RED)❌ E2E Tests: FAILING$(NC)"; \
fi; \
echo ""; \
echo "2. Running Parser Tests:"; \
if $(ZIG) test src/parser/tokenizer.zig 2>/dev/null; then \
echo "$(GREEN)✅ Tokenizer Tests: PASSING$(NC)"; \
TOKENIZER_PASS=1; \
else \
echo "$(RED)❌ Tokenizer Tests: FAILING$(NC)"; \
fi; \
if $(ZIG) test src/parser/parser.zig 2>/dev/null; then \
echo "$(GREEN)✅ Parser Tests: PASSING$(NC)"; \
PARSER_PASS=1; \
else \
echo "$(RED)❌ Parser Tests: FAILING$(NC)"; \
fi; \
echo ""; \
echo "3. Running Formatter Tests:"; \
if $(ZIG) test src/formatter/colors.zig 2>/dev/null; then \
echo "$(GREEN)✅ Colors Tests: PASSING$(NC)"; \
COLORS_PASS=1; \
else \
echo "$(RED)❌ Colors Tests: FAILING$(NC)"; \
fi; \
if $(ZIG) test test/test_json_formatter.zig 2>/dev/null; then \
echo "$(GREEN)✅ JSON Formatter Tests: PASSING$(NC)"; \
FORMATTER_PASS=1; \
else \
echo "$(RED)❌ JSON Formatter Tests: FAILING$(NC)"; \
fi; \
echo ""; \
echo "4. Testing Actual Binary Functionality:"; \
if echo '{"test": "value"}' | $(BINARY) > /dev/null 2>&1; then \
echo "$(GREEN)✅ Binary JSON Processing: WORKING$(NC)"; \
BINARY_PASS=1; \
else \
echo "$(RED)❌ Binary JSON Processing: BROKEN$(NC)"; \
fi; \
if NO_COLOR=1 echo '{"test": "value"}' | $(BINARY) | grep -v '\x1b\[' > /dev/null 2>&1; then \
echo "$(GREEN)✅ NO_COLOR Support: WORKING$(NC)"; \
NO_COLOR_PASS=1; \
else \
echo "$(RED)❌ NO_COLOR Support: BROKEN$(NC)"; \
fi; \
echo ""; \
echo "=== REAL COVERAGE ASSESSMENT ==="; \
TOTAL_TESTS=$$(($$E2E_PASS + $$TOKENIZER_PASS + $$PARSER_PASS + $$COLORS_PASS + $$FORMATTER_PASS + $$BINARY_PASS + $$NO_COLOR_PASS)); \
COVERAGE_PERCENT=$$(($$TOTAL_TESTS * 100 / 7)); \
echo "Passing test suites: $$TOTAL_TESTS / 7"; \
echo "Functional coverage: $$COVERAGE_PERCENT%"; \
mkdir -p tmp; \
echo "Real Coverage Analysis Report" > tmp/coverage.txt; \
echo "Test Suites Passing: $$TOTAL_TESTS / 7" >> tmp/coverage.txt; \
echo "Overall coverage: $$COVERAGE_PERCENT%" >> tmp/coverage.txt; \
if [ $$COVERAGE_PERCENT -ge 85 ]; then \
echo "$(GREEN)✅ COVERAGE EXCELLENT: $$COVERAGE_PERCENT% (exceeds 60% minimum)$(NC)"; \
elif [ $$COVERAGE_PERCENT -ge 60 ]; then \
echo "$(GREEN)✅ COVERAGE GOOD: $$COVERAGE_PERCENT% (meets 60% minimum)$(NC)"; \
else \
echo "$(RED)❌ COVERAGE INSUFFICIENT: $$COVERAGE_PERCENT% (below 60% minimum)$(NC)"; \
exit 1; \
fi
# Run E2E tests specifically
.PHONY: test-e2e
test-e2e:
@echo "Running E2E tests..."
@$(ZIG) test test/e2e_tests.zig
# Run E2E v2 tests specifically
.PHONY: test-e2e-v2
test-e2e-v2:
@echo "Running E2E v2 tests..."
@$(ZIG) test test/e2e_v2_tests.zig
# Clean build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
@rm -rf zig-out
@rm -rf zig-cache
@rm -rf tmp
@echo "Clean complete."
# Create tmp directory if needed
.PHONY: setup
setup:
@mkdir -p tmp
# Help target
.PHONY: help
help:
@echo "CC Streamer Makefile Commands:"
@echo ""
@echo " make - Build the project (default)"
@echo " make build - Build the project"
@echo " make release - Build in release mode"
@echo " make run - Build and run the application"
@echo " make run-args ARGS=\"...\" - Run with arguments"
@echo " make test - Run unit tests"
@echo " make test-basic - Run basic test suite"
@echo " make test-manual - Run manual tests"
@echo " make test-real - Run comprehensive real tests with coverage"
@echo " make test-e2e - Run E2E tests only"
@echo " make test-e2e-v2 - Run E2E v2 tests only"
@echo " make clean - Clean build artifacts"
@echo " make setup - Create necessary directories"
@echo " make help - Show this help message"
@echo ""
@echo "Environment Variables:"
@echo " NO_COLOR=1 - Disable colored output"
@echo " ARGS=\"...\" - Arguments to pass to the application"
# Display all targets
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'