Skip to content

Commit

Permalink
do not name pytest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ydaveluy committed Dec 29, 2023
1 parent c8a822a commit c3988f6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ option(XSMP_BUILD_EXAMPLES "whether or not examples should be built"
option(XSMP_ENABLE_INSTALL "whether or not to enable the install rule" ${XSMP_MASTER_PROJECT})
option(XSMP_ENABLE_CODECOVERAGE "Enable code coverage testing support" OFF)
option(XSMP_BUILD_WITH_WARNINGS "Enable all compiler warnings" OFF)
set(XSMP_BUILD_EXAMPLES ON)


set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -581,8 +582,7 @@ if(XSMP_BUILD_TESTS)

gtest_discover_tests(XsmpTests)
include(Pytest)
pytest_discover_tests(PythonTest)

pytest_discover_tests()
endif(XSMP_BUILD_TESTS)

if(XSMP_BUILD_EXAMPLES)
Expand Down
16 changes: 9 additions & 7 deletions cmake/Pytest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ endif()

find_package(Python COMPONENTS Interpreter Development)

function(pytest_discover_tests NAME)
function(pytest_discover_tests)
cmake_parse_arguments(
PARSE_ARGV 1 "" ""
"WORKING_DIRECTORY;TRIM_FROM_NAME;BUNDLE_TESTS"
PARSE_ARGV 0 "" ""
"NAME;WORKING_DIRECTORY;TRIM_FROM_NAME;BUNDLE_TESTS"
"LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT"
)

Expand Down Expand Up @@ -74,8 +74,11 @@ function(pytest_discover_tests NAME)
set(_BUNDLE_TESTS $ENV{BUNDLE_PYTHON_TESTS})
endif()


set(ctest_file_base "${CMAKE_CURRENT_BINARY_DIR}/${NAME}")
if (NOT _NAME)
set(_NAME "pytest")
endif()

set(ctest_file_base "${CMAKE_CURRENT_BINARY_DIR}/${_NAME}")
set(ctest_include_file "${ctest_file_base}_include.cmake")


Expand All @@ -89,15 +92,14 @@ function(pytest_discover_tests NAME)
"include(\"${_PYTEST_DISCOVER_TESTS_SCRIPT}\")" "\n"
"pytest_discover_tests_impl(" "\n"
" PYTHON_EXECUTABLE" " [==[" "${Python_EXECUTABLE}" "]==]" "\n"
" TEST_GROUP_NAME" " [==[" "${NAME}" "]==]" "\n"
" TEST_GROUP_NAME" " [==[" "${_NAME}" "]==]" "\n"
" BUNDLE_TESTS" " [==[" "${_BUNDLE_TESTS}" "]==]" "\n"
" LIB_ENV_PATH" " [==[" "${LIB_ENV_PATH}" "]==]" "\n"
" LIBRARY_PATH" " [==[" "${libpath}" "]==]" "\n"
" PYTHON_PATH" " [==[" "${pythonpath}" "]==]" "\n"
" TRIM_FROM_NAME" " [==[" "${_TRIM_FROM_NAME}" "]==]" "\n"
" WORKING_DIRECTORY" " [==[" "${_WORKING_DIRECTORY}" "]==]" "\n"
" ENVIRONMENT" " [==[" "${_ENVIRONMENT}" "]==]" "\n"
" PROJECT_SOURCE_DIR" " [==[" "${PROJECT_SOURCE_DIR}" "]==]" "\n"
" CTEST_FILE" " [==[" "${ctest_tests_file}" "]==]" "\n"
")" "\n"
"include(\"${ctest_tests_file}\")" "\n"
Expand Down
5 changes: 2 additions & 3 deletions cmake/PytestAddTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(pytest_discover_tests_impl)
cmake_parse_arguments(
""
""
"PYTHON_EXECUTABLE;TEST_GROUP_NAME;BUNDLE_TESTS;LIB_ENV_PATH;LIBRARY_PATH;PYTHON_PATH;TRIM_FROM_NAME;WORKING_DIRECTORY;ENVIRONMENT;PROJECT_SOURCE_DIR;CTEST_FILE"
"PYTHON_EXECUTABLE;TEST_GROUP_NAME;BUNDLE_TESTS;LIB_ENV_PATH;LIBRARY_PATH;PYTHON_PATH;TRIM_FROM_NAME;WORKING_DIRECTORY;ENVIRONMENT;CTEST_FILE"
""
${ARGN}
)
Expand Down Expand Up @@ -84,7 +84,7 @@ function(pytest_discover_tests_impl)
"${_TRIM_FROM_NAME}" "" test_name "${test_name}")
endif()

set(test_name "${_TEST_GROUP_NAME}.${test_name}")
set(test_name "${_TEST_GROUP_NAME}/${test_name}")
set(test_case "${_WORKING_DIRECTORY}/${test_case}")

string(APPEND _content
Expand Down Expand Up @@ -131,7 +131,6 @@ if(CMAKE_SCRIPT_MODE_FILE)
TRIM_FROM_NAME ${TRIM_FROM_NAME}
WORKING_DIRECTORY ${WORKING_DIRECTORY}
ENVIRONMENT ${ENVIRONMENT}
PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}
CTEST_FILE ${CTEST_FILE}
)
endif(CMAKE_SCRIPT_MODE_FILE)
2 changes: 1 addition & 1 deletion examples/project1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ include(CTest)


include(Pytest)
pytest_discover_tests(xsmp_example_project1Test)
pytest_discover_tests()

0 comments on commit c3988f6

Please sign in to comment.