on master help sign in
test: move tests from manage.sh to Makefile
1075f58Markus Heiser
Makefile+36−11
@@ -43,7 +43,7 @@ PHONY += uninstall
43uninstall: pyenvuninstall
43uninstall: pyenvuninstall
44
44
45PHONY += clean
45PHONY += clean
46−clean: pyclean node.clean
46+clean: pyclean node.clean test.clean
47 $(call cmd,common_clean)
47 $(call cmd,common_clean)
48
48
49PHONY += run
49PHONY += run
@@ -160,27 +160,52 @@ PHONY += docker
160docker:
160docker:
161 $(Q)./manage.sh docker_build
161 $(Q)./manage.sh docker_build
162
162
163+# gecko
164+# -----
165+
166+PHONY += gecko.driver
167+gecko.driver:
168+ $(PY_ENV_ACT); ./manage.sh install_geckodriver
163
169
164# test
170# test
165# ----
171# ----
166
172
167−PHONY += test test.pylint test.pep8 test.unit test.robot
173+PHONY += test test.pylint test.pep8 test.unit test.coverage test.robot
168
174
169−test: test.pylint test.pep8 test.unit test.robot
175+test: test.pylint test.pep8 test.unit gecko.driver test.robot
170
176
171# TODO: balance linting with pylint
177# TODO: balance linting with pylint
172test.pylint: pyenvinstall
178test.pylint: pyenvinstall
179+ $(call cmd,pylint,\
173− $(call cmd,pylint,searx/preferences.py)
180+ searx/preferences.py \
174− $(call cmd,pylint,searx/testing.py)
181+ searx/testing.py \
182+ )
183+
184+# ignored rules:
185+# E402 module level import not at top of file
186+# W503 line break before binary operator
175
187
176test.pep8: pyenvinstall
188test.pep8: pyenvinstall
177− $(PY_ENV_ACT); ./manage.sh pep8_check
189+ @echo "TEST pep8"
190+ $(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests
178
191
179test.unit: pyenvinstall
192test.unit: pyenvinstall
180− $(PY_ENV_ACT); ./manage.sh unit_tests
193+ @echo "TEST tests/unit"
181−
194+ $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
195+
196+test.coverage: pyenvinstall
197+ @echo "TEST unit test coverage"
198+ $(Q)$(PY_ENV_ACT); \
199+ python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
200+ && coverage report \
201+ && coverage html \
202+
182−test.robot: pyenvinstall
203+test.robot: pyenvinstall gecko.driver
183− $(PY_ENV_ACT); ./manage.sh install_geckodriver
204+ @echo "TEST robot"
184− $(PY_ENV_ACT); ./manage.sh robot_tests
205+ $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
206+
207+test.clean:
208+ @echo "CLEAN intermediate test stuff"
209+ $(Q)rm -rf geckodriver.log .coverage coverage/
185
210
186.PHONY: $(PHONY)
211.PHONY: $(PHONY)
manage.sh−42
@@ -70,40 +70,6 @@ locales() {
70 pybabel compile -d "$SEARX_DIR/translations"
70 pybabel compile -d "$SEARX_DIR/translations"
71}
71}
72
72
73−pep8_check() {
74− echo '[!] Running pep8 check'
75− # ignored rules:
76− # E402 module level import not at top of file
77− # W503 line break before binary operator
78− pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" "$SEARX_DIR" "$BASE_DIR/tests"
79−}
80−
81−unit_tests() {
82− echo '[!] Running unit tests'
83− python -m nose2 -s "$BASE_DIR/tests/unit"
84−}
85−
86−py_test_coverage() {
87− echo '[!] Running python test coverage'
88− PYTHONPATH="`pwd`" python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \
89− && coverage report \
90− && coverage html
91−}
92−
93−robot_tests() {
94− echo '[!] Running robot tests'
95− PYTHONPATH="`pwd`" python "$SEARX_DIR/testing.py" robot
96−}
97−
98−tests() {
99− set -e
100− pep8_check
101− unit_tests
102− install_geckodriver
103− robot_tests
104− set +e
105−}
106−
107
73
108#
74#
109# Web
75# Web
@@ -220,14 +186,6 @@ Commands
220 Build
186 Build
221 -----
187 -----
222 locales - Compile locales
188 locales - Compile locales
223−
224− Tests
225− -----
226− unit_tests - Run unit tests
227− pep8_check - Pep8 validation
228− robot_tests - Run selenium tests
229− tests - Run all python tests (pep8, unit, robot_tests)
230− py_test_coverage - Unit test coverage
231"
189"
232}
190}
233
191