diff --git a/CMakeLists.txt b/CMakeLists.txt index 39b69a7..43b3455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) diff --git a/cmake/Pytest.cmake b/cmake/Pytest.cmake index 8162f9c..43a1983 100644 --- a/cmake/Pytest.cmake +++ b/cmake/Pytest.cmake @@ -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" ) @@ -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") @@ -89,7 +92,7 @@ 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" @@ -97,7 +100,6 @@ function(pytest_discover_tests NAME) " 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" diff --git a/cmake/PytestAddTests.cmake b/cmake/PytestAddTests.cmake index 34910f5..48a6ecd 100644 --- a/cmake/PytestAddTests.cmake +++ b/cmake/PytestAddTests.cmake @@ -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} ) @@ -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 @@ -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) diff --git a/examples/project1/CMakeLists.txt b/examples/project1/CMakeLists.txt index 8229d26..5be4b71 100644 --- a/examples/project1/CMakeLists.txt +++ b/examples/project1/CMakeLists.txt @@ -34,4 +34,4 @@ include(CTest) include(Pytest) -pytest_discover_tests(xsmp_example_project1Test) +pytest_discover_tests()