Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-11-03 03:48:47 +0300
committerCampbell Barton <campbell@blender.org>2022-11-03 03:51:52 +0300
commitb320597697d8c28798342ffc45a330f86ed276ca (patch)
tree9a676f017b98f98666bf399fd86ccf3eb22e4bea /tests
parentbad55d56bc71ec9b5f2478de6a1ce350b474de57 (diff)
Tests: don't create byte-code cache when calling Python from SVN
Creating `__pycache__` directories in SVN's lib/ directory can cause updating SVN to fail. Add the -B flag when TEST_PYTHON_EXE from LIBDIR is used so so Python doesn't generate this cache.
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt13
-rw-r--r--tests/blender_as_python_module/CMakeLists.txt2
-rw-r--r--tests/python/CMakeLists.txt2
3 files changed, 15 insertions, 2 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 68fcfc89b96..d2fbec7059f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -31,6 +31,19 @@ elseif(NOT EXISTS ${TEST_PYTHON_EXE})
endif()
+# Include these arguments before all others, they must not interfere with Python execution.
+set(TEST_PYTHON_EXE_EXTRA_ARGS)
+
+# Check if this a Blender managed Python installation, if so, don't add `*.pyc` files.
+if(LIBDIR)
+ cmake_path(IS_PREFIX LIBDIR "${TEST_PYTHON_EXE}" NORMALIZE _is_prefix)
+ if(_is_prefix)
+ # Keep the Python in Blender's SVN LIBDIR pristine, to avoid conflicts on updating.
+ set(TEST_PYTHON_EXE_EXTRA_ARGS "-B")
+ endif()
+ unset(_is_prefix)
+endif()
+
# For testing with Valgrind
# set(TEST_BLENDER_EXE valgrind --track-origins=yes --error-limit=no ${TEST_BLENDER_EXE})
diff --git a/tests/blender_as_python_module/CMakeLists.txt b/tests/blender_as_python_module/CMakeLists.txt
index 6e0ce524903..7387d5c41bf 100644
--- a/tests/blender_as_python_module/CMakeLists.txt
+++ b/tests/blender_as_python_module/CMakeLists.txt
@@ -8,7 +8,7 @@ function(add_blender_as_python_module_test testname testscript)
add_test(
NAME ${testname}
- COMMAND ${TEST_PYTHON_EXE} ${testscript} ${ARGN}
+ COMMAND ${TEST_PYTHON_EXE} ${TEST_PYTHON_EXE_EXTRA_ARGS} ${testscript} ${ARGN}
)
# On macOS, asan library must be loaded early.
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index b3decc06161..0d74cfafda5 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -41,7 +41,7 @@ function(add_python_test testname testscript)
add_test(
NAME ${testname}
- COMMAND ${TEST_PYTHON_EXE} ${testscript} ${ARGN}
+ COMMAND ${TEST_PYTHON_EXE} ${TEST_PYTHON_EXE_EXTRA_ARGS} ${testscript} ${ARGN}
)
set_tests_properties(${testname} PROPERTIES ENVIRONMENT
LSAN_OPTIONS=exitcode=0:$ENV{LSAN_OPTIONS}