Skip to content

Commit 5ce00e5

Browse files
committed
Relocate multiple-interpreters tests
1 parent d0819cc commit 5ce00e5

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

tests/CMakeLists.txt

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ set(PYBIND11_TEST_FILES
157157
test_methods_and_attributes
158158
test_modules
159159
test_multiple_inheritance
160-
test_multiple_interpreters.py
160+
test_multiple_interpreters/test_multiple_interpreters.py
161161
test_native_enum
162162
test_numpy_array
163163
test_numpy_dtypes
@@ -578,24 +578,8 @@ add_custom_target(
578578
USES_TERMINAL)
579579

580580
if(NOT PYBIND11_CUDA_TESTS)
581-
# This module doesn't get mixed with other test modules because those aren't subinterpreter safe.
582-
pybind11_add_module(mod_per_interpreter_gil THIN_LTO mod_per_interpreter_gil.cpp)
583-
pybind11_add_module(mod_shared_interpreter_gil THIN_LTO mod_shared_interpreter_gil.cpp)
584-
set_target_properties(mod_per_interpreter_gil PROPERTIES LIBRARY_OUTPUT_DIRECTORY
585-
"$<1:${CMAKE_CURRENT_BINARY_DIR}>")
586-
set_target_properties(mod_shared_interpreter_gil PROPERTIES LIBRARY_OUTPUT_DIRECTORY
587-
"$<1:${CMAKE_CURRENT_BINARY_DIR}>")
588-
if(PYBIND11_TEST_SMART_HOLDER)
589-
target_compile_definitions(
590-
mod_per_interpreter_gil
591-
PUBLIC -DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE
592-
)
593-
target_compile_definitions(
594-
mod_shared_interpreter_gil
595-
PUBLIC -DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE
596-
)
597-
endif()
598-
add_dependencies(pytest mod_per_interpreter_gil mod_shared_interpreter_gil)
581+
# Multiple interpreters tests are in a separate subdirectory
582+
add_subdirectory(test_multiple_interpreters)
599583
endif()
600584

601585
if(PYBIND11_TEST_OVERRIDE)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# CMakeLists.txt -- Build system for the pybind11 multiple interpreters test suite
2+
#
3+
# Copyright (c) 2015 Wenzel Jakob <[email protected]>
4+
#
5+
# All rights reserved. Use of this source code is governed by a
6+
# BSD-style license that can be found in the LICENSE file.
7+
8+
set(PYBIND11_MULTIPLE_INTERPRETERS_TEST_FILES test_multiple_interpreters.py)
9+
10+
# These modules don't get mixed with other test modules because those aren't subinterpreter safe.
11+
pybind11_add_module(mod_per_interpreter_gil THIN_LTO mod_per_interpreter_gil.cpp)
12+
pybind11_add_module(mod_shared_interpreter_gil THIN_LTO mod_shared_interpreter_gil.cpp)
13+
pybind11_enable_warnings(mod_per_interpreter_gil)
14+
pybind11_enable_warnings(mod_shared_interpreter_gil)
15+
16+
# Put the built modules next to `pybind11_tests.so` so that the test scripts can find them.
17+
get_target_property(pybind11_tests_output_directory pybind11_tests LIBRARY_OUTPUT_DIRECTORY)
18+
set_target_properties(mod_per_interpreter_gil PROPERTIES LIBRARY_OUTPUT_DIRECTORY
19+
"${pybind11_tests_output_directory}")
20+
set_target_properties(mod_shared_interpreter_gil PROPERTIES LIBRARY_OUTPUT_DIRECTORY
21+
"${pybind11_tests_output_directory}")
22+
23+
if(PYBIND11_TEST_SMART_HOLDER)
24+
target_compile_definitions(
25+
mod_per_interpreter_gil
26+
PUBLIC -DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE)
27+
target_compile_definitions(
28+
mod_shared_interpreter_gil
29+
PUBLIC -DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE)
30+
endif()
31+
32+
add_dependencies(pytest mod_per_interpreter_gil mod_shared_interpreter_gil)
33+
34+
# Convert relative to full file names and add to pytest test files
35+
list(TRANSFORM PYBIND11_MULTIPLE_INTERPRETERS_TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
36+
list(APPEND PYBIND11_ABS_PYTEST_FILES ${PYBIND11_MULTIPLE_INTERPRETERS_TEST_FILES})
37+
set(PYBIND11_ABS_PYTEST_FILES
38+
${PYBIND11_ABS_PYTEST_FILES}
39+
PARENT_SCOPE)

tests/mod_per_interpreter_gil.cpp renamed to tests/test_multiple_interpreters/mod_per_interpreter_gil.cpp

File renamed without changes.

tests/mod_shared_interpreter_gil.cpp renamed to tests/test_multiple_interpreters/mod_shared_interpreter_gil.cpp

File renamed without changes.

tests/test_multiple_interpreters.py renamed to tests/test_multiple_interpreters/test_multiple_interpreters.py

File renamed without changes.

0 commit comments

Comments
 (0)