-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (128 loc) · 4.07 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
# -- Variables -----------------------------------------------------------------
BOOKDOWN_DIRECTORY := Bookdown
SPHINX_DIRECTORY := Sphinx
SPHINX_INPUT_DIRECTORY := Documentation/API
INDEX_FILE := Documentation/Introduction.md
OUTPUT_NAME := Documentation
PDF_FILE := $(BOOKDOWN_DIRECTORY)/$(OUTPUT_NAME).pdf
EPUB_FILE := $(BOOKDOWN_DIRECTORY)/$(OUTPUT_NAME).epub
HTML_FILE := $(BOOKDOWN_DIRECTORY)/$(OUTPUT_NAME).html
ifeq ($(OS), Windows_NT)
OPERATING_SYSTEM := windows
# Disable Prysk Pytest plugin
export PYTEST_DISABLE_PLUGIN_AUTOLOAD := ""
else
OS_NAME := $(shell uname -s)
ifeq ($(OS_NAME), Linux)
OPERATING_SYSTEM := linux
else
OPERATING_SYSTEM := mac
endif
endif
# -- Rules ---------------------------------------------------------------------
run: check test hardware-test
# =========
# = Tests =
# =========
check:
flake8
mypy mytoolit
pylint mytoolit
.PHONY: test
test: pytest-test sphinx-doctest
test-no-hardware: pytest-test-no-hardware
# ----------
# - Pytest -
# ----------
pytest-test:
pytest
pytest-test-no-hardware:
pytest --ignore-glob='*network.py' \
--ignore-glob='*commander.py' \
--ignore-glob='*read_data.t' \
--ignore-glob='*sth_name.t' \
--ignore-glob='*store_data.t' \
--ignore-glob='*measure.t' \
--ignore='Documentation'
# -------------------
# - Sphinx Doctests -
# -------------------
.PHONY: sphinx-doctest sphinx-doctest-$(OPERATING_SYSTEM)
sphinx-doctest: sphinx-doctest-$(OPERATING_SYSTEM)
# Somehow the pytest test seem to cause a problematic state on Linux,
# since afterwards the Sphinx doctest often fail, reporting problems about
# unsuccessful requests to the hardware.
#
# Example:
#
# > NoResponseError: Unable to enable streaming of first measurement channel
# of “STH 1”).
#
# Therefore we reset the system before we run the tests on Linux.
sphinx-doctest-linux: reset-stu sphinx-doctest-general
sphinx-doctest-windows: sphinx-doctest-general
sphinx-doctest-mac: sphinx-doctest-general
.PHONY: reset-stu
reset-stu:
icon stu reset
# Note: The pytest plugin `pytest-sphinx` (version 0.6.3) does unfortunately not
# find our API documentation doctests.
.PHONY: sphinx-doctest-general
sphinx-doctest-general:
sphinx-build -M doctest $(SPHINX_INPUT_DIRECTORY) $(SPHINX_DIRECTORY)
# ------------------
# - Hardware Tests -
# ------------------
hardware-test: run-hardware-test open-test-report-$(OPERATING_SYSTEM)
run-hardware-test:
test-sth -v
test-stu -k eeprom -k connection
open-test-report-windows:
@powershell -c "Invoke-Item (Join-Path $$PWD 'STH Test.pdf')"
@powershell -c "Invoke-Item (Join-Path $$PWD 'STU Test.pdf')"
open-test-report-mac:
@open 'STH Test.pdf' 'STU Test.pdf'
open-test-report-linux:
@if [ -z "$(DISPLAY)" ]; \
then \
printf "Please check the files “STH Test.pdf” and “STU Test.pdf”\n"; \
else \
xdg-open 'STH Test.pdf'; \
xdg-open 'STU Test.pdf'; \
fi
# =================
# = Documentation =
# =================
# ------------
# - Bookdown -
# ------------
doc: init $(EPUB_FILE) $(HTML_FILE) $(PDF_FILE) cleanup
# Copy pictures to repository root and create diagrams
init:
Rscript -e "dir.create('Pictures')"
Rscript -e "file.copy('Documentation/Pictures', '.', recursive=T)"
# Remove pictures from repository root
cleanup:
Rscript -e "unlink('Pictures', recursive = TRUE)"
epub: init $(EPUB_FILE) cleanup
html: init $(HTML_FILE) cleanup
pdf: init $(PDF_FILE) cleanup
# Generate EPUB document
$(EPUB_FILE):
Rscript -e "bookdown::render_book('$(INDEX_FILE)', 'bookdown::epub_book')"
# Generate (GitBook) HTML document
$(HTML_FILE):
Rscript -e "bookdown::render_book('$(INDEX_FILE)', 'bookdown::gitbook')"
Rscript -e "file.rename('$(HTML_FILE)', '$(BOOKDOWN_DIRECTORY)/index.html')"
# Generate PDF
$(PDF_FILE):
Rscript -e "bookdown::render_book('$(INDEX_FILE)', 'bookdown::pdf_book')"
clean: cleanup
Rscript -e "unlink('$(BOOKDOWN_DIRECTORY)', recursive = TRUE)"
Rscript -e "unlink('$(SPHINX_DIRECTORY)', recursive = TRUE)"
# -------
# - API -
# -------
.PHONY: doc-api
doc-api:
sphinx-build -M html $(SPHINX_INPUT_DIRECTORY) $(SPHINX_DIRECTORY)