-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (122 loc) · 4.95 KB
/
Copy pathMakefile
File metadata and controls
141 lines (122 loc) · 4.95 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
.PHONY: test test-verbose test-legacy test-basic test-file test-error test-modes test-edge clean help benchmark benchmark-quick benchmark-save benchmark-compare pytest pytest-cov pytest-parallel pytest-slow install-test
help:
@echo "Bitcask Test Suite (pytest)"
@echo "============================"
@echo "Testing:"
@echo " make test - Run all tests with pytest"
@echo " make test-verbose - Run tests with detailed output"
@echo " make test-quiet - Run tests with summary only"
@echo " make test-cov - Run tests with coverage report"
@echo " make test-fast - Run tests in parallel"
@echo ""
@echo "Test specific groups:"
@echo " make test-basic - Test basic operations"
@echo " make test-file - Test file management"
@echo " make test-error - Test error handling"
@echo " make test-modes - Test modes & concurrency"
@echo " make test-edge - Test edge cases"
@echo " make test-thread - Test thread safety"
@echo ""
@echo "Benchmarks:"
@echo " make benchmark - Run performance benchmark"
@echo " make benchmark-quick - Quick benchmark (1000 ops)"
@echo ""
@echo "Maintenance:"
@echo " make clean - Remove test artifacts"
@echo " make install-test - Install test dependencies"
# Run all tests with pytest
test:
@echo "Running Bitcask Test Suite with pytest"
@echo "======================================"
@env/bin/python -m pytest bitcask/__tests__/ -v
# Run tests with verbose output
test-verbose:
@echo "Running Bitcask Test Suite (Verbose)"
@echo "===================================="
@cd bitcask/__tests__ && PYTHONPATH=../.. python3 -m unittest \
test_basic_operations \
test_file_management \
test_error_handling \
test_modes_concurrency \
test_edge_cases \
-v
# Run all tests including legacy (78 tests)
test-legacy:
@echo "Running All Tests Including Legacy (78 tests)"
@echo "============================================="
@cd bitcask/__tests__ && PYTHONPATH=../.. python3 -m unittest discover -v
# Individual test groups
test-basic:
@echo "Running Basic Operations Tests"
@cd bitcask/__tests__ && PYTHONPATH=../.. python3 -m unittest test_basic_operations -v
test-file:
@echo "Running File Management Tests"
@cd bitcask/__tests__ && PYTHONPATH=../.. python3 -m unittest test_file_management -v
test-error:
@echo "Running Error Handling Tests"
@cd bitcask/__tests__ && PYTHONPATH=../.. python3 -m unittest test_error_handling -v
test-modes:
@echo "Running Modes & Concurrency Tests"
@cd bitcask/__tests__ && PYTHONPATH=../.. python3 -m unittest test_modes_concurrency -v
test-edge:
@echo "Running Edge Cases Tests"
@cd bitcask/__tests__ && PYTHONPATH=../.. python3 -m unittest test_edge_cases -v
# Performance benchmarks
benchmark:
@echo "Running Bitcask Performance Benchmark"
@echo "======================================"
@env/bin/python tools/benchmark.py
benchmark-quick:
@echo "Running Quick Benchmark (1000 ops)"
@echo "=================================="
@env/bin/python tools/benchmark.py --quick
benchmark-save:
@echo "Saving baseline performance..."
@env/bin/python tools/benchmark.py > benchmark_baseline.txt 2>&1
@echo "✓ Baseline saved to benchmark_baseline.txt"
benchmark-compare:
@if [ ! -f benchmark_baseline.txt ]; then \
echo "No baseline found. Run 'make benchmark-save' first."; \
exit 1; \
fi
@echo "Running benchmark for comparison..."
@env/bin/python tools/benchmark.py > benchmark_current.txt 2>&1
@echo ""
@echo "Performance Comparison:"
@echo "======================="
@diff -u benchmark_baseline.txt benchmark_current.txt | grep "ops/sec" || true
@echo ""
@echo "Full diff saved to benchmark_diff.txt"
@diff -u benchmark_baseline.txt benchmark_current.txt > benchmark_diff.txt || true
# Install test dependencies
install-test:
@echo "Installing test dependencies..."
@env/bin/pip install -e ".[test]"
@echo "✓ Test dependencies installed"
# Run tests with coverage report
test-cov:
@echo "Running tests with coverage..."
@env/bin/python -m pytest bitcask/__tests__/ --cov=bitcask --cov-report=term-missing
# Run tests in parallel for speed
test-fast:
@echo "Running tests in parallel..."
@env/bin/python -m pytest bitcask/__tests__/ -n auto
# Run thread safety tests
test-thread:
@echo "Running Thread Safety Tests"
@env/bin/python -m pytest bitcask/__tests__/test_thread_safety*.py -v
# Run tests marked as slow
test-slow:
@echo "Running slow tests..."
@env/bin/python -m pytest bitcask/__tests__/ -v -m slow
# Clean up test artifacts
clean:
@echo "Cleaning up test artifacts..."
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@find . -type f -name "*.pyo" -delete 2>/dev/null || true
@find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
@rm -rf htmlcov/ .coverage coverage.xml 2>/dev/null || true
@rm -f benchmark_*.txt 2>/dev/null || true
@echo "Clean complete."