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
|
# SPDX-FileCopyrightText: 2011-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# note: this isn't needed for building,
# its just for some convenience targets.
# 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')
# Filter out files which use `bpy`.
PY_FILES_MYPY=$(filter-out \
./__init__.py \
./bl_extension_cli.py \
./bl_extension_monkeypatch.py \
./bl_extension_notify.py \
./bl_extension_ops.py \
./bl_extension_ui.py \
./bl_extension_utils.py \
./extensions_map_from_legacy_addons.py \
./wheel_manager.py \
./example_extension/__init__.py \
./example_extension/foo.py \
,$(PY_FILES))
PY_FILES_MYPY_STANDALONE= \
./bl_extension_utils.py \
./bl_extension_cli.py
EXTRA_WATCH_FILES=Makefile
# For tests that launch Blender directly.
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
# `--no-namespace-packages` is needed otherwise `./cli/blender_ext.py` loads in parent modules
# (the Blender add-on which imports `bpy`).
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
@cd "$(BASE_DIR)" && ruff check $(PY_FILES_MYPY)
@cd "$(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:
@cd "$(BASE_DIR)" && \
pylint $(PY_FILES) \
--enable=useless-suppression \
--disable=C0103,C0111,C0201,C0301,C0302,C0415,R0401,R1702,R1705,R0902,R0903,R0913,E0611,E0401,I1101,R0801,C0209,W0511,W0718,W0719,C0413,R0911,R0912,R0914,R0915 \
--msg-template='{abspath}:{line}:{column}: {msg_id}: {msg} ({symbol})'
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
@$(MAKE) -C "$(BASE_DIR)" test_cli;
@$(MAKE) -C "$(BASE_DIR)" test_blender;
@$(MAKE) -C "$(BASE_DIR)" test_cli_blender;
watch_test: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) test; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
# -----------------------------------------------------------------------------
# Tests (Individual)
# python3 ./tests/test_cli.py
test_cli: FORCE
@cd "$(BASE_DIR)" && \
USE_HTTP=0 \
$(PYTHON_BIN) ./tests/test_cli.py
@cd "$(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
@cd "$(BASE_DIR)" && \
ASAN_OPTIONS=check_initialization_order=0:leak_check_at_exit=0 \
$(BLENDER_BIN) \
--background --factory-startup --online-mode -noaudio \
--python ./tests/test_blender.py -- --verbose
watch_test_blender: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) test_blender; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
test_cli_blender: FORCE
@cd "$(BASE_DIR)" && \
env BLENDER_BIN=$(BLENDER_BIN) \
$(PYTHON_BIN) ./tests/test_cli_blender.py
watch_test_cli_blender: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
env BLENDER_BIN=$(BLENDER_BIN) \
$(MAKE) test_cli_blender; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
test_path_pattern_match: FORCE
@cd "$(BASE_DIR)" && \
$(PYTHON_BIN) ./tests/test_path_pattern_match.py
watch_test_path_pattern_match: FORCE
@cd "$(BASE_DIR)" && \
while true; do \
$(MAKE) test_path_pattern_match; \
inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
tput clear; \
done
FORCE:
|