Extensions: makefile tweaks

- Add a top-level "test" target that runs all other tests.
- Order "watch_*" convenience targets directly after the tests
  they watch.
This commit is contained in:
Campbell Barton
2024-05-28 16:13:12 +10:00
parent 0dca908191
commit 8366ea8798

View File

@@ -5,7 +5,7 @@
# note: this isn't needed for building,
# its just for some convenience targets.
# Needed for when tests are run from another directory: `make -C ./path/to/this/directory`
# Needed for when tests are run from another directory: `make -C ./scripts/addons_core`
BASE_DIR := ${CURDIR}
PY_FILES=$(shell find ./ -type f -name '*.py')
@@ -35,6 +35,10 @@ EXTRA_WATCH_FILES=Makefile
BLENDER_BIN?=$(shell which blender)
PYTHON_BIN?=$(shell which python3)
# -----------------------------------------------------------------------------
# Checking Utilities
pep8: FORCE
@flake8 $(PY_FILES) --ignore=E501,E302,E123,E126,E128,E129,E124,E122,W504
@@ -43,31 +47,83 @@ pep8: FORCE
check_mypy: FORCE
@mypy --no-namespace-packages --strict $(PY_FILES_MYPY)
@mypy --strict --follow-imports=skip $(PY_FILES_MYPY_STANDALONE)
watch_check_mypy:
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) check_mypy; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
$(PY_FILES_MYPY) \
./bl_extension_utils.py ; \
tput clear; \
done
check_ruff: FORCE
@env --chdir="$(BASE_DIR)" ruff check $(PY_FILES_MYPY)
@env --chdir="$(BASE_DIR)" ruff check $(PY_FILES_MYPY_STANDALONE)
watch_check_ruff:
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) check_ruff; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
$(PY_FILES_MYPY) \
./bl_extension_utils.py ; \
tput clear; \
done
check_pylint:
@env --chdir="$(BASE_DIR)" \
pylint $(PY_FILES) \
--disable=C0111,C0301,C0302,C0103,C0415,R1705,R0902,R0903,R0913,E0611,E0401,I1101,R0801,C0209,W0511,W0718,W0719,C0413,R0911,R0912,R0914,R0915
watch_check_pylint:
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) check_pylint; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
# -----------------------------------------------------------------------------
# Tests (All)
test: FORCE
@env --chdir="$(BASE_DIR)" $(MAKE) test_cli;
@env --chdir="$(BASE_DIR)" $(MAKE) test_blender;
@env --chdir="$(BASE_DIR)" $(MAKE) test_cli_blender;
watch_test: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) test_cli; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
# -----------------------------------------------------------------------------
# Tests (Individual)
# python3 ./tests/test_cli.py
test: FORCE
test_cli: FORCE
@env --chdir="$(BASE_DIR)" \
USE_HTTP=0 \
$(PYTHON_BIN) ./tests/test_cli.py
@env --chdir="$(BASE_DIR)" \
USE_HTTP=1 \
$(PYTHON_BIN) ./tests/test_cli.py
watch_test_cli: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) test_cli; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
# NOTE: these rely on the blender binary.
test_blender: FORCE
@env --chdir="$(BASE_DIR)" \
ASAN_OPTIONS=check_initialization_order=0:leak_check_at_exit=0 \
$(BLENDER_BIN) --background --factory-startup -noaudio --python ./tests/test_blender.py -- --verbose
watch_test_blender: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
@@ -79,7 +135,6 @@ watch_test_blender: FORCE
test_cli_blender: FORCE
@env BLENDER_BIN=$(BLENDER_BIN) \
$(PYTHON_BIN) ./tests/test_cli_blender.py
watch_test_cli_blender: FORCE
@while true; do \
env BLENDER_BIN=$(BLENDER_BIN) \
@@ -91,22 +146,6 @@ watch_test_cli_blender: FORCE
test_path_pattern_match: FORCE
@env --chdir="$(BASE_DIR)" \
$(PYTHON_BIN) ./tests/test_path_pattern_match.py
# https://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/
# mkfs -q /dev/ram1 8192
# mkdir -p /ramcache
# sudo mount /dev/ram1 /ramcache
# sudo chmod 777 /ramcache
# mkdir /ramcache/tmp
watch_test: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) test; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
watch_test_path_pattern_match: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
@@ -115,33 +154,4 @@ watch_test_path_pattern_match: FORCE
tput clear; \
done
watch_check_mypy:
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) check_mypy; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
$(PY_FILES_MYPY) \
./bl_extension_utils.py ; \
tput clear; \
done
watch_check_ruff:
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) check_ruff; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
$(PY_FILES_MYPY) \
./bl_extension_utils.py ; \
tput clear; \
done
watch_check_pylint:
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) check_pylint; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
FORCE: