forked from INTI-CMNB/KiBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
170 lines (148 loc) · 6.74 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
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
#!/usr/bin/make
PY_COV=python3-coverage
PYTEST=pytest-3
REFDIR=tests/reference/5_1_7/
REFILL=tests/board_samples/zone-refill.kicad_pcb
CWD := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))
USER_ID=$(shell id -u)
GROUP_ID=$(shell id -g)
ifneq ("$(wildcard *.yaml)","")
$(error Move away any config file)
endif
ifneq ("$(wildcard *.sch)","")
$(error Move away any schematic file)
endif
ifneq ("$(wildcard tests/board_samples/bom.xml-bak*)","")
$(error Revert tests/board_samples/bom.xml-bak)
endif
deb:
fakeroot dpkg-buildpackage -uc -b
lint: doc
# flake8 --filename is broken
ln -sf src/kiplot kiplot.py
ln -sf src/kibot kibot.py
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
pre-commit run -a
rm kiplot.py
rm kibot.py
test_tmp: lint
$(PY_COV) erase
$(PYTEST)
$(PY_COV) report
test: lint
rm -rf output
rm -f example.kiplot.yaml
rm -f example.kibot.yaml
rm -f tests/.local
$(PY_COV) erase
$(PYTEST) --test_dir output
$(PY_COV) report
$(PY_COV) html
x-www-browser htmlcov/index.html
test1:
rm -rf output
rm -f example.kiplot.yaml
rm -f example.kibot.yaml
rm -f tests/.local
$(PY_COV) erase
$(PYTEST) --log-cli-level debug -k "test_bom_ok" --test_dir output
$(PY_COV) report
$(PY_COV) html
#x-www-browser htmlcov/index.html
@echo "********************" Output
@cat output/*/output.txt
#@echo "********************" Error
#@cat output/*/error.txt
test_docker_local_1:
rm -rf output
rm -f tests/.local
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" setsoft/kicad_auto_test:latest \
/bin/bash -c "flake8 . --count --statistics ; python3-coverage run -a src/kibot --help-outputs > /dev/null; pytest-3 --log-cli-level debug -k 'test_erc_warning_2' --test_dir output ; $(PY_COV) html; chown -R $(USER_ID):$(GROUP_ID) output/ tests/board_samples/ tests/.config/kiplot/plugins/__pycache__/ tests/test_plot/fake_pcbnew/__pycache__/ tests/.config/kibot/plugins/__pycache__/ .coverage htmlcov/"
#$(PY_COV) report
#x-www-browser htmlcov/index.html
rm .coverage
test_docker_local_1_ki6:
rm -rf output
rm -f tests/.local
#$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" setsoft/kicad_auto_test:ki6 \
/bin/bash -c "flake8 . --count --statistics ; python3-coverage run -a src/kibot --help-outputs > /dev/null; pytest-3 --log-cli-level debug -k 'test_kicad_conf_user' --test_dir output ; $(PY_COV) html; chown -R $(USER_ID):$(GROUP_ID) output/ tests/board_samples/ tests/.config/kiplot/plugins/__pycache__/ tests/test_plot/fake_pcbnew/__pycache__/ tests/.config/kibot/plugins/__pycache__/ .coverage htmlcov/"
#$(PY_COV) report
#x-www-browser htmlcov/index.html
test_docker_local:
rm -rf output
rm -f tests/.local
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" setsoft/kicad_auto_test:latest \
/bin/bash -c "flake8 . --count --statistics ; python3-coverage run -a src/kibot --help-outputs ; pytest-3 --test_dir output ; $(PY_COV) html; chown -R $(USER_ID):$(GROUP_ID) output/ tests/board_samples/ .coverage htmlcov/"
$(PY_COV) report
x-www-browser htmlcov/index.html
test_docker_local_ki6:
rm -rf output
rm -f tests/.local
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" setsoft/kicad_auto_test:ki6 \
/bin/bash -c "flake8 . --count --statistics ; python3-coverage run -a src/kibot --help-outputs ; pytest-3 --test_dir output ; $(PY_COV) html; chown -R $(USER_ID):$(GROUP_ID) output/ tests/board_samples/ .coverage htmlcov/"
$(PY_COV) report
x-www-browser htmlcov/index.html
docker_shell:
docker run -it --rm -v $(CWD):$(CWD) --workdir="$(CWD)" \
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$(DISPLAY) \
--user $(USER_ID):$(GROUP_ID) \
--volume="/etc/group:/etc/group:ro" \
--volume="/etc/passwd:/etc/passwd:ro" \
--volume="/etc/shadow:/etc/shadow:ro" \
--volume="/home/$(USER):/home/$(USER):rw" \
setsoft/kicad_auto_test:latest /bin/bash
single_test:
rm -rf pp
-$(PY_COV) run -a src/kibot --help-list-outputs > /dev/null
-$(PYTEST) --log-cli-level debug -k "$(SINGLE_TEST)" --test_dir pp
@echo "********************" Output
@cat pp/*/output.txt
@echo "********************" Error
@tail -n 30 pp/*/error.txt
@rm -f tests/input_samples/bom.ini
single_tests:
rm -rf pp
# 12 threads, for a 6 core CPU w/HT. Almost 4 times faster for BoM tests.
-$(PYTEST) -n 12 --log-cli-level debug -k "$(SINGLE_TEST)" --test_dir pp
@rm -f tests/input_samples/bom.ini
deb_clean:
fakeroot debian/rules clean
gen_ref:
# Reference outputs, must be manually inspected if regenerated
pcbnew_do export --output_name bom-F_Cu+F_SilkS.pdf --scaling 4 --pads 0 --no-title --monochrome --separate tests/board_samples/bom.kicad_pcb $(REFDIR) F.Cu F.SilkS
cp -a $(REFILL).refill $(REFILL)
src/kibot -c tests/yaml_samples/pdf_zone-refill.kibot.yaml -b tests/board_samples/zone-refill.kicad_pcb -d $(REFDIR)
src/kibot -c tests/yaml_samples/print_pcb_zone-refill.kibot.yaml -b tests/board_samples/zone-refill.kicad_pcb -d $(REFDIR)
src/kibot -c tests/yaml_samples/print_pdf_no_inductors_1.kibot.yaml -e tests/board_samples/test_v5.sch -d $(REFDIR)
mv "$(REFDIR)no_inductor/test_v5-schematic_(no_L).pdf" $(REFDIR)
rmdir $(REFDIR)no_inductor/
src/kibot -c tests/yaml_samples/print_svg_no_inductors_1.kibot.yaml -e tests/board_samples/test_v5.sch -d $(REFDIR)
mv "$(REFDIR)no_inductor/test_v5-schematic_(no_L).svg" $(REFDIR)
-@rm -rf $(REFDIR)no_inductor/
src/kibot -b tests/board_samples/kibom-variant_4.kicad_pcb -c tests/yaml_samples/pdf_variant_1.kibot.yaml -d $(REFDIR)
src/kibot -b tests/board_samples/kibom-variant_3.kicad_pcb -c tests/yaml_samples/pcbdraw_variant_1.kibot.yaml -d $(REFDIR)
src/kibot -b tests/board_samples/kibom-variant_3.kicad_pcb -c tests/yaml_samples/pcbdraw_variant_2.kibot.yaml -d $(REFDIR)
src/kibot -b tests/board_samples/kibom-variant_3.kicad_pcb -c tests/yaml_samples/print_pcb_variant_1.kibot.yaml -d $(REFDIR)
cp -a $(REFILL).ok $(REFILL)
doc:
make -C docs
py_build:
python3 setup.py sdist bdist_wheel
pypi_upload: py_clean py_build
python3 -m twine upload dist/*
py_clean:
@rm -rf .pybuild build dist kibot.egg-info
.PHONY: deb deb_clean lint test test_local gen_ref doc py_build pypi_upload py_clean