1 # SPDX-FileCopyrightText: 2011-2023 Blender Authors
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # note: this isn't needed for building,
6 # its just for some convenience targets.
8 # Needed for when tests are run from another directory: `make -C ./path/to/this/directory`
11 PY_FILES
=$(shell find .
/ -type f
-name
'*.py')
12 # Filter out files which use `bpy`.
13 PY_FILES_MYPY
=$(filter-out \
15 .
/bl_extension_cli.py \
16 .
/bl_extension_local.py \
17 .
/bl_extension_monkeypatch.py \
18 .
/bl_extension_notify.py \
19 .
/bl_extension_ops.py \
20 .
/bl_extension_ui.py \
21 .
/bl_extension_utils.py \
23 .
/example_extension
/__init__.py \
24 .
/example_extension
/foo.py \
27 PY_FILES_MYPY_STANDALONE
= \
28 .
/bl_extension_utils.py \
29 .
/bl_extension_cli.py \
32 EXTRA_WATCH_FILES
=Makefile
34 # For tests that launch Blender directly.
35 BLENDER_BIN?
=$(shell which blender
)
36 PYTHON_BIN?
=$(shell which python3
)
39 @flake8
$(PY_FILES
) --ignore
=E501
,E302
,E123
,E126
,E128
,E129
,E124
,E122
,W504
41 # `--no-namespace-packages` is needed otherwise `./cli/blender_ext.py` loads in parent modules
42 # (the Blender add-on which imports `bpy`).
44 @mypy
--no-namespace-packages
--strict
$(PY_FILES_MYPY
)
45 @mypy
--strict
--follow-imports
=skip
$(PY_FILES_MYPY_STANDALONE
)
48 @env
--chdir
="$(BASE_DIR)" ruff
check $(PY_FILES_MYPY
)
49 @env
--chdir
="$(BASE_DIR)" ruff
check $(PY_FILES_MYPY_STANDALONE
)
52 @env
--chdir
="$(BASE_DIR)" \
54 --disable
=C0111
,C0301
,C0302
,C0103
,C0415
,R1705
,R0902
,R0903
,R0913
,E0611
,E0401
,I1101
,R0801
,C0209
,W0511
,W0718
,W0719
,C0413
,R0911
,R0912
,R0914
,R0915
56 # python3 ./tests/test_cli.py
58 @env
--chdir
="$(BASE_DIR)" \
60 $(PYTHON_BIN
) .
/tests
/test_cli.py
61 @env
--chdir
="$(BASE_DIR)" \
63 $(PYTHON_BIN
) .
/tests
/test_cli.py
65 # NOTE: these rely on the blender binary.
67 @env
--chdir
="$(BASE_DIR)" \
68 ASAN_OPTIONS
=check_initialization_order
=0:leak_check_at_exit
=0 \
69 $(BLENDER_BIN
) --background
--factory-startup
-noaudio
--python .
/tests
/test_blender.py
-- --verbose
71 watch_test_blender
: FORCE
72 @cd
"$(BASE_DIR)" && \
74 $(MAKE
) test_blender
; \
75 inotifywait
-q
-e close_write
$(EXTRA_WATCH_FILES
) $(PY_FILES
) ; \
79 test_cli_blender
: FORCE
80 @env BLENDER_BIN
=$(BLENDER_BIN
) \
81 $(PYTHON_BIN
) .
/tests
/test_cli_blender.py
83 watch_test_cli_blender
: FORCE
85 env BLENDER_BIN
=$(BLENDER_BIN
) \
86 $(MAKE
) test_cli_blender
; \
87 inotifywait
-q
-e close_write
$(EXTRA_WATCH_FILES
) $(PY_FILES
) ; \
92 # https://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/
93 # mkfs -q /dev/ram1 8192
95 # sudo mount /dev/ram1 /ramcache
96 # sudo chmod 777 /ramcache
100 @cd
"$(BASE_DIR)" && \
103 inotifywait
-q
-e close_write
$(EXTRA_WATCH_FILES
) $(PY_FILES
) ; \
108 @cd
"$(BASE_DIR)" && \
110 $(MAKE
) check_mypy
; \
111 inotifywait
-q
-e close_write
$(EXTRA_WATCH_FILES
) \
113 .
/bl_extension_utils.py
; \
118 @cd
"$(BASE_DIR)" && \
120 $(MAKE
) check_ruff
; \
121 inotifywait
-q
-e close_write
$(EXTRA_WATCH_FILES
) \
123 .
/bl_extension_utils.py
; \
128 @cd
"$(BASE_DIR)" && \
130 $(MAKE
) check_pylint
; \
131 inotifywait
-q
-e close_write
$(EXTRA_WATCH_FILES
) $(PY_FILES
) ; \