on master help sign in
test: move tests from manage.sh to Makefile

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commit1075f58a722fad7801a7b8397cd7e6de31d99da2 authorMarkus Heiser <markus.heiser@darmarit.de> dateThu 26 Mar 2020, 18:41 (7 years ago) parente7fbefa
2 files changed+36−53
Makefile+36−11 manage.sh−42
Makefile+36−11
@@ -43,7 +43,7 @@ PHONY += uninstall
4343uninstall: pyenvuninstall
4444
4545PHONY += clean
46−clean: pyclean node.clean
46+clean: pyclean node.clean test.clean
4747 $(call cmd,common_clean)
4848
4949PHONY += run
@@ -160,27 +160,52 @@ PHONY += docker
160160docker:
161161 $(Q)./manage.sh docker_build
162162
163+# gecko
164+# -----
165+
166+PHONY += gecko.driver
167+gecko.driver:
168+ $(PY_ENV_ACT); ./manage.sh install_geckodriver
163169
164170# test
165171# ----
166172
167−PHONY += test test.pylint test.pep8 test.unit test.robot
173+PHONY += test test.pylint test.pep8 test.unit test.coverage test.robot
168174
169−test: test.pylint test.pep8 test.unit test.robot
175+test: test.pylint test.pep8 test.unit gecko.driver test.robot
170176
171177# TODO: balance linting with pylint
172178test.pylint: pyenvinstall
173− $(call cmd,pylint,searx/preferences.py)
174− $(call cmd,pylint,searx/testing.py)
179+ $(call cmd,pylint,\
180+ searx/preferences.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
175187
176188test.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
178191
179192test.unit: pyenvinstall
180− $(PY_ENV_ACT); ./manage.sh unit_tests
181−
182−test.robot: pyenvinstall
183− $(PY_ENV_ACT); ./manage.sh install_geckodriver
184− $(PY_ENV_ACT); ./manage.sh robot_tests
193+ @echo "TEST tests/unit"
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+
203+test.robot: pyenvinstall gecko.driver
204+ @echo "TEST robot"
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/
185210
186211.PHONY: $(PHONY)
manage.sh−42
@@ -70,40 +70,6 @@ locales() {
7070 pybabel compile -d "$SEARX_DIR/translations"
7171}
7272
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−
10773
10874#
10975# Web
@@ -220,14 +186,6 @@ Commands
220186 Build
221187 -----
222188 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
231189"
232190}
233191