Skip to content
Snippets Groups Projects
Commit ec4ed45c authored by Jean-Matthieu Etancelin's avatar Jean-Matthieu Etancelin
Browse files

Fix python test discovering

parent 32e3fb52
No related branches found
No related tags found
No related merge requests found
......@@ -7,14 +7,11 @@ find_python_module(pytest REQUIRED)
set(py_src_dirs
fields
particular_solvers
domain
integrator
obstacle
operator
physics
problem
tools
numerics
)
if(USE_MPI)
......@@ -22,15 +19,57 @@ if(USE_MPI)
${py_src_dirs} mpi)
endif()
### JM : Bub, GLOB_RECURSE utilse les chemins relatifs avec ../
# foreach(testdir ${py_src_dirs})
# file(GLOB_RECURSE py_test_files "${test_dir}" RELATIVE_PATH parmepy/*/test_*.py)
# endforeach()
## Build a list of test_*.py files recursively for each directory of parmepy/${py_src_dirs}
set(py_test_files)
foreach(testdir ${py_src_dirs})
file(GLOB_RECURSE testfiles
RELATIVE ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/parmepy/${testdir}/test_*.py)
set(py_test_files
${py_test_files} ${testfiles})
endforeach()
## Handling doctest in *.py files recursively for each directory of parmepy/${py_src_dirs}
## that names are not __init__ or test_ and that contains '>>>'
set(py_doctest_files)
foreach(testdir ${py_src_dirs})
file(GLOB_RECURSE py_test_files "${test_dir}" RELATIVE_PATH parmepy/*/test_*.py)
file(GLOB_RECURSE testfiles
RELATIVE ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/parmepy/${testdir}/*.py)
foreach(testfile ${testfiles})
if(NOT ${testfile} MATCHES "__init__|test_")
file(STRINGS ${testfile} test_doctest
REGEX ">>>")
if(NOT "${test_doctest}" STREQUAL "")
set(py_doctest_files
${py_doctest_files} ${testfile})
endif()
endif()
endforeach()
endforeach()
## Adding tests
message(STATUS "=== TESTS === ")
## Add test_*.py files
foreach(testfile ${py_test_files})
get_filename_component(testName ${testfile} NAME_WE)
message(STATUS "Add test ${testName} ...")
message(STATUS "Add test ${testfile} ...")
add_test(${testName} py.test -v ${testfile})
endforeach()
## Add files containing doctests
foreach(testfile ${py_doctest_files})
get_filename_component(testName ${testfile} NAME_WE)
message(STATUS "Add test from doc doctest_${testName} ...")
add_test("doctest_${testName}" py.test -v ${testfile})
endforeach()
message(STATUS "===")
#add_test(NAME topology COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 py.test -v ${CMAKE_SOURCE_DIR}/parmepy/mpi/tests/test_topology.py)
# add_test(NAME topology COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1 py.test -v ${CMAKE_SOURCE_DIR}/parmepy/mpi/tests/test_topology.py)
......@@ -38,4 +77,3 @@ endforeach()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment