-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (90 loc) · 3.69 KB
/
Makefile
File metadata and controls
118 lines (90 loc) · 3.69 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
# Bubble Sort on a Turing Machine — Makefile
# ============================================================================
PYTHON ?= python3
YAML_DECIMAL = bubble_sort.yaml
YAML_UNARY = bubble_sort_unary.yaml
# ============================================================================
# Default target
# ============================================================================
.PHONY: help
help:
@echo ""
@echo " Bubble Sort on a Turing Machine"
@echo " ================================"
@echo ""
@echo " make test Run the full test suite (unittest discover)"
@echo " make test-decimal Run only the decimal bubble-sort tests"
@echo " make test-unary Run only the unary bubble-sort tests"
@echo " make test-emulator Run only the emulator / fixture tests"
@echo " make test-legacy Run the original test_bubble_sort.py runner"
@echo " make test-all Run both the unittest suite and the legacy runner"
@echo " make test-verbose Run the full test suite with verbose output"
@echo ""
@echo " make run-decimal Run the emulator on bubble_sort.yaml"
@echo " make run-unary Run the emulator on bubble_sort_unary.yaml"
@echo " make run-decimal-v Run decimal with verbose trace"
@echo " make run-unary-v Run unary with verbose trace"
@echo " make run FILE=<path> Run the emulator on an arbitrary YAML file"
@echo ""
@echo " make generate Regenerate bubble_sort.yaml via generate_yaml.py"
@echo " make generate INPUT=<digits>"
@echo " Generate a YAML for a custom digit string"
@echo ""
@echo " make clean Remove __pycache__ and *.pyc files"
@echo " make check Alias for 'make test'"
@echo ""
# ============================================================================
# Testing
# ============================================================================
.PHONY: test test-decimal test-unary test-emulator test-legacy test-all test-verbose check
test:
$(PYTHON) -m unittest discover -s tests
test-verbose:
$(PYTHON) -m unittest discover -s tests -v
test-decimal:
$(PYTHON) -m unittest tests.test_bubble_sort_decimal -v
test-unary:
$(PYTHON) -m unittest tests.test_bubble_sort_unary -v
test-emulator:
$(PYTHON) -m unittest tests.test_emulator -v
test-legacy:
$(PYTHON) test_bubble_sort.py
test-all: test test-legacy
check: test
# ============================================================================
# Running
# ============================================================================
.PHONY: run run-decimal run-unary run-decimal-v run-unary-v
run-decimal:
$(PYTHON) emulator.py $(YAML_DECIMAL)
run-unary:
$(PYTHON) emulator.py $(YAML_UNARY)
run-decimal-v:
$(PYTHON) emulator.py $(YAML_DECIMAL) -v
run-unary-v:
$(PYTHON) emulator.py $(YAML_UNARY) -v
# Run an arbitrary YAML file: make run FILE=tests/fixtures/busy_beaver4.yaml
run:
ifdef FILE
$(PYTHON) emulator.py $(FILE)
else
@echo "Usage: make run FILE=<path-to-yaml>"
@exit 1
endif
# ============================================================================
# Code generation
# ============================================================================
.PHONY: generate
INPUT ?= 327154
generate:
$(PYTHON) generate_yaml.py $(INPUT) > $(YAML_DECIMAL)
@echo "Generated $(YAML_DECIMAL) with input '$(INPUT)'"
# ============================================================================
# Cleanup
# ============================================================================
.PHONY: clean
clean:
find . -type d -name __pycache__ -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
@echo "Cleaned."