From 5aad770106ce865a2b4638aecbe85a79c8518772 Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Fri, 21 Jan 2022 09:21:52 +0100 Subject: [PATCH] run C++ unit tests during build option, enabled if devMode=ON (#640) --- .gitignore | 5 + CMakeLists.txt | 5 +- res/cmake/def.cmake | 186 +++++++++++++++++- res/cmake/options.cmake | 3 + res/cmake/test.cmake | 157 --------------- .../amr/data/field/coarsening/CMakeLists.txt | 7 +- .../multiphysics_integrator/CMakeLists.txt | 1 + tests/core/data/gridlayout/CMakeLists.txt | 6 +- tests/core/numerics/ampere/CMakeLists.txt | 5 +- tests/core/numerics/faraday/CMakeLists.txt | 4 +- .../core/numerics/interpolator/CMakeLists.txt | 5 +- tests/core/numerics/ohm/CMakeLists.txt | 5 +- tests/core/numerics/pusher/CMakeLists.txt | 5 +- tests/diagnostic/CMakeLists.txt | 2 + tests/initializer/CMakeLists.txt | 2 + 15 files changed, 216 insertions(+), 182 deletions(-) diff --git a/.gitignore b/.gitignore index 89033321e..b270b8a47 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,9 @@ compile_commands.json phare_outputs* CMakeLists.txt.user .log +tools/cmake.sh +.cmake.* +perf.* +**/*.h5 +.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index b2da494d9..a639c8625 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,9 +39,6 @@ if(PHARE_WITH_CCACHE) endif() #### -include("${PHARE_PROJECT_DIR}/res/cmake/test.cmake") -include("${PHARE_PROJECT_DIR}/res/cmake/bench.cmake") - #******************************************************************************* # PHARE source code add_subdirectory(src/core) @@ -53,5 +50,7 @@ add_subdirectory(src/python3) add_subdirectory(src/phare) #******************************************************************************* +include("${PHARE_PROJECT_DIR}/res/cmake/test.cmake") +include("${PHARE_PROJECT_DIR}/res/cmake/bench.cmake") print_phare_options() diff --git a/res/cmake/def.cmake b/res/cmake/def.cmake index 6e854a394..2ed5180b8 100644 --- a/res/cmake/def.cmake +++ b/res/cmake/def.cmake @@ -16,6 +16,8 @@ endif(withIPO) set (PHARE_WITH_CCACHE FALSE) if(devMode) # -DdevMode=ON + set(testDuringBuild ON) + # Having quotes on strings here has lead to quotes being added to the compile string, so avoid. set (_Werr ${PHARE_WERROR_FLAGS} -Wall -Wextra -pedantic -Werror -Wno-unused-variable -Wno-unused-parameter) @@ -52,7 +54,14 @@ function(phare_sanitize_ san cflags ) endfunction(phare_sanitize_) if (asan) # -Dasan=ON - phare_sanitize_("-fsanitize=address -shared-libsan" "-fno-omit-frame-pointer" ) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + phare_sanitize_("-fsanitize=address" "-fno-omit-frame-pointer" ) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + phare_sanitize_("-fsanitize=address -shared-libsan" "-fno-omit-frame-pointer" ) + else() + message(FATAL_ERROR "ASAN Unhandled compiler: ${CMAKE_CXX_COMPILER_ID}") + endif() + set(testDuringBuild OFF) # can need LD_PRELOAD/etc endif(asan) if (ubsan) # -Dubsan=ON @@ -61,4 +70,179 @@ endif(ubsan) # msan is not supported - it's not practical to configure - use valgrind +# test functions below + +# public test functions +# +# add_phare_test($binary $directory) +# execute binary in target directory, with mpirun when -DtestMPI=ON +# +# add_python3_test($name $file $directory) +# launch python3 file described by name in target directory, with mpirun when -DtestMPI=ON +# +# add_no_mpi_phare_test($binary $directory) +# execute binary in target directory, does not run when -DtestMPI=ON +# +# add_no_mpi_python3_test($name $file $directory) +# launch python3 file described by name in target directory, does not run when -DtestMPI=ON +# +# phare_exec(level target exe directory) +# execute exe identified by target in directory +# if level >= PHARE_EXEC_LEVEL_MIN AND level <= PHARE_EXEC_LEVEL_MAX +# +# phare_python3_exec(level target file directory $ARGS) +# execute file identified by target in directory +# if level >= PHARE_EXEC_LEVEL_MIN AND level <= PHARE_EXEC_LEVEL_MAX +# +# Note to developers - do not use cmake variable function arguments for functions +# phare_python3_exec +# phare_mpi_python3_exec +# if these function calls are to files executing python unit tests as they will interfere + +if (test AND ${PHARE_EXEC_LEVEL_MIN} GREATER 0) # 0 = no tests + + if (NOT DEFINED PHARE_MPI_PROCS) + set(PHARE_MPI_PROCS 1) + if(testMPI) + set(PHARE_MPI_PROCS 2) + endif() + endif() + + function(set_exe_paths_ binary) + set_property(TEST ${binary} PROPERTY ENVIRONMENT "PYTHONPATH=${PHARE_PYTHONPATH}") + # ASAN detects leaks by default, even in system/third party libraries + set_property(TEST ${binary} APPEND PROPERTY ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0") + endfunction(set_exe_paths_) + + function(add_phare_test_ binary directory) + target_compile_options(${binary} PRIVATE ${PHARE_WERROR_FLAGS} -DPHARE_HAS_HIGHFIVE=${PHARE_HAS_HIGHFIVE}) + set_exe_paths_(${binary}) + set_property(TEST ${binary} APPEND PROPERTY ENVIRONMENT GMON_OUT_PREFIX=gprof.${binary}) + set_property(TEST ${binary} APPEND PROPERTY ENVIRONMENT PHARE_MPI_PROCS=${PHARE_MPI_PROCS}) + if(testDuringBuild) + add_custom_command( + TARGET ${binary} + POST_BUILD + WORKING_DIRECTORY ${directory} + COMMAND ${CMAKE_CTEST_COMMAND} -C $ -R \"^${binary}$$\" --output-on-failures + ) + endif(testDuringBuild) + endfunction(add_phare_test_) + + function(add_no_mpi_phare_test binary directory) + if(NOT testMPI OR (testMPI AND forceSerialTests)) + add_test(NAME ${binary} COMMAND ./${binary} WORKING_DIRECTORY ${directory}) + add_phare_test_(${binary} ${directory}) + else() + # this prevents building targets even when added via "add_executable" + set_target_properties(${binary} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + endif() + endfunction(add_no_mpi_phare_test) + + function(add_no_mpi_python3_test name file directory) + if(NOT testMPI OR (testMPI AND forceSerialTests)) + add_test(NAME py3_${name} COMMAND python3 -u ${file} WORKING_DIRECTORY ${directory}) + set_exe_paths_(py3_${name}) + endif() + endfunction(add_no_mpi_python3_test) + + if(testMPI) + function(add_phare_test binary directory) + add_test(NAME ${binary} COMMAND mpirun -n ${PHARE_MPI_PROCS} ./${binary} WORKING_DIRECTORY ${directory}) + add_phare_test_(${binary} ${directory}) + endfunction(add_phare_test) + + function(add_python3_test name file directory) + add_test(NAME py3_${name} COMMAND mpirun -n ${PHARE_MPI_PROCS} python3 -u ${file} WORKING_DIRECTORY ${directory}) + set_exe_paths_(py3_${name}) + endfunction(add_python3_test) + + function(add_mpi_python3_test N name file directory) + add_test(NAME py3_${name}_mpi_n_${N} COMMAND mpirun -n ${N} python3 ${file} WORKING_DIRECTORY ${directory}) + set_exe_paths_(py3_${name}_mpi_n_${N}) + endfunction(add_mpi_python3_test) + + else() + function(add_phare_test binary directory) + add_no_mpi_phare_test(${binary} ${directory}) + endfunction(add_phare_test) + + function(add_python3_test name file directory) + add_no_mpi_python3_test(${name} ${file} ${directory}) + endfunction(add_python3_test) + + function(add_mpi_python3_test N name file directory) + # do nothing + endfunction(add_mpi_python3_test) + endif(testMPI) + + + function(add_phare_build_test binary directory) + endfunction(add_phare_build_test) + + + if(DEFINED GTEST_ROOT) + set(GTEST_ROOT ${GTEST_ROOT} CACHE PATH "Path to googletest") + find_package(GTest REQUIRED) + set(GTEST_LIBS GTest::GTest GTest::Main) + else() + set(GTEST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/googletest) + + if (NOT EXISTS ${GTEST_ROOT}) + execute_process(COMMAND ${Git} clone https://github.com/google/googletest ${GTEST_ROOT}) + endif() + + add_subdirectory(subprojects/googletest) + set(GTEST_INCLUDE_DIRS + $ + $) + set(GTEST_LIBS gtest gmock) + + endif() + + function(phare_exec level target exe directory) + if(${level} GREATER_EQUAL ${PHARE_EXEC_LEVEL_MIN} AND ${level} LESS_EQUAL ${PHARE_EXEC_LEVEL_MAX}) + add_test(NAME ${target} COMMAND ${exe} WORKING_DIRECTORY ${directory}) + endif() + endfunction(phare_exec) + # use + # phare_exec(1 test_id ./binary ${CMAKE_CURRENT_BINARY_DIR}) + + function(phare_python3_exec level target file directory) + if(${level} GREATER_EQUAL ${PHARE_EXEC_LEVEL_MIN} AND ${level} LESS_EQUAL ${PHARE_EXEC_LEVEL_MAX}) + string (REPLACE ";" " " CLI_ARGS "${ARGN}") + add_test(NAME py3_${target} COMMAND python3 -u ${file} ${CLI_ARGS} WORKING_DIRECTORY ${directory}) + set_exe_paths_(py3_${target}) + endif() + endfunction(phare_python3_exec) + # use + # phare_python3_exec(1 test_id script.py ${CMAKE_CURRENT_BINARY_DIR} $ARGS) + + + function(phare_mpi_python3_exec level N target file directory) + if(${level} GREATER_EQUAL ${PHARE_EXEC_LEVEL_MIN} AND ${level} LESS_EQUAL ${PHARE_EXEC_LEVEL_MAX}) + string (REPLACE ";" " " CLI_ARGS "${ARGN}") + if(${N} EQUAL 1) + add_test( + NAME py3_${target} + COMMAND python3 -u ${file} ${CLI_ARGS} + WORKING_DIRECTORY ${directory}) + set_exe_paths_(py3_${target}) + else() + add_test( + NAME py3_${target}_mpi_n_${N} + COMMAND mpirun -n ${N} python3 -u ${file} ${CLI_ARGS} + WORKING_DIRECTORY ${directory}) + set_exe_paths_(py3_${target}_mpi_n_${N}) + endif() + endif() + endfunction(phare_mpi_python3_exec) + # use + # phare_mpi_python3_exec(1 2 test_id script.py ${CMAKE_CURRENT_BINARY_DIR} $ARGS) + + set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} ${PHARE_PROJECT_DIR}) + + enable_testing() + +endif() diff --git a/res/cmake/options.cmake b/res/cmake/options.cmake index 2a20ba3b2..66efd8fc5 100644 --- a/res/cmake/options.cmake +++ b/res/cmake/options.cmake @@ -66,6 +66,9 @@ option(withCaliper "Use LLNL Caliper" OFF) # -DlowResourceTests=ON option(lowResourceTests "Disable heavy tests for CI (2d/3d/etc" OFF) +# -DtestDuringBuild=ON enabled if devMode=ON, disabled if asan=ON (needs LD_PRELOAD) +option(testDuringBuild "Runs C++ unit tests after they are built" OFF) + # Controlling the activation of tests if (NOT DEFINED PHARE_EXEC_LEVEL_MIN) diff --git a/res/cmake/test.cmake b/res/cmake/test.cmake index 3ee0d8229..f217ca97b 100644 --- a/res/cmake/test.cmake +++ b/res/cmake/test.cmake @@ -1,166 +1,9 @@ -# public test functions -# -# add_phare_test($binary $directory) -# execute binary in target directory, with mpirun when -DtestMPI=ON -# -# add_python3_test($name $file $directory) -# launch python3 file described by name in target directory, with mpirun when -DtestMPI=ON -# -# add_no_mpi_phare_test($binary $directory) -# execute binary in target directory, does not run when -DtestMPI=ON -# -# add_no_mpi_python3_test($name $file $directory) -# launch python3 file described by name in target directory, does not run when -DtestMPI=ON -# -# phare_exec(level target exe directory) -# execute exe identified by target in directory -# if level >= PHARE_EXEC_LEVEL_MIN AND level <= PHARE_EXEC_LEVEL_MAX -# -# phare_python3_exec(level target file directory $ARGS) -# execute file identified by target in directory -# if level >= PHARE_EXEC_LEVEL_MIN AND level <= PHARE_EXEC_LEVEL_MAX -# -# Note to developers - do not use cmake variable function arguments for functions -# phare_python3_exec -# phare_mpi_python3_exec -# if these function calls are to files executing python unit tests as they will interfere if (test AND ${PHARE_EXEC_LEVEL_MIN} GREATER 0) # 0 = no tests - if (NOT DEFINED PHARE_MPI_PROCS) - set(PHARE_MPI_PROCS 1) - if(testMPI) - set(PHARE_MPI_PROCS 2) - endif() - endif() - - function(set_exe_paths_ binary) - set_property(TEST ${binary} PROPERTY ENVIRONMENT "PYTHONPATH=${PHARE_PYTHONPATH}") - # ASAN detects leaks by default, even in system/third party libraries - set_property(TEST ${binary} APPEND PROPERTY ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0") - endfunction(set_exe_paths_) - - function(add_phare_test_ binary) - target_compile_options(${binary} PRIVATE ${PHARE_WERROR_FLAGS} -DPHARE_HAS_HIGHFIVE=${PHARE_HAS_HIGHFIVE}) - set_exe_paths_(${binary}) - set_property(TEST ${binary} APPEND PROPERTY ENVIRONMENT GMON_OUT_PREFIX=gprof.${binary}) - set_property(TEST ${binary} APPEND PROPERTY ENVIRONMENT PHARE_MPI_PROCS=${PHARE_MPI_PROCS}) - endfunction(add_phare_test_) - - function(add_no_mpi_phare_test binary directory) - if(NOT testMPI OR (testMPI AND forceSerialTests)) - add_test(NAME ${binary} COMMAND ./${binary} WORKING_DIRECTORY ${directory}) - add_phare_test_(${binary}) - else() - # this prevents building targets even when added via "add_executable" - set_target_properties(${binary} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) - endif() - endfunction(add_no_mpi_phare_test) - - function(add_no_mpi_python3_test name file directory) - if(NOT testMPI OR (testMPI AND forceSerialTests)) - add_test(NAME py3_${name} COMMAND python3 -u ${file} WORKING_DIRECTORY ${directory}) - set_exe_paths_(py3_${name}) - endif() - endfunction(add_no_mpi_python3_test) - - if(testMPI) - function(add_phare_test binary directory) - add_test(NAME ${binary} COMMAND mpirun -n ${PHARE_MPI_PROCS} ./${binary} WORKING_DIRECTORY ${directory}) - add_phare_test_(${binary}) - endfunction(add_phare_test) - - function(add_python3_test name file directory) - add_test(NAME py3_${name} COMMAND mpirun -n ${PHARE_MPI_PROCS} python3 -u ${file} WORKING_DIRECTORY ${directory}) - set_exe_paths_(py3_${name}) - endfunction(add_python3_test) - - function(add_mpi_python3_test N name file directory) - add_test(NAME py3_${name}_mpi_n_${N} COMMAND mpirun -n ${N} python3 ${file} WORKING_DIRECTORY ${directory}) - set_exe_paths_(py3_${name}_mpi_n_${N}) - endfunction(add_mpi_python3_test) - - else() - function(add_phare_test binary directory) - add_no_mpi_phare_test(${binary} ${directory}) - endfunction(add_phare_test) - - function(add_python3_test name file directory) - add_no_mpi_python3_test(${name} ${file} ${directory}) - endfunction(add_python3_test) - - function(add_mpi_python3_test N name file directory) - # do nothing - endfunction(add_mpi_python3_test) - endif(testMPI) - - - if(DEFINED GTEST_ROOT) - set(GTEST_ROOT ${GTEST_ROOT} CACHE PATH "Path to googletest") - find_package(GTest REQUIRED) - set(GTEST_LIBS GTest::GTest GTest::Main) - else() - set(GTEST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/googletest) - - if (NOT EXISTS ${GTEST_ROOT}) - execute_process(COMMAND ${Git} clone https://github.com/google/googletest ${GTEST_ROOT}) - endif() - - add_subdirectory(subprojects/googletest) - set(GTEST_INCLUDE_DIRS - $ - $) - set(GTEST_LIBS gtest gmock) - - endif() - - function(phare_exec level target exe directory) - if(${level} GREATER_EQUAL ${PHARE_EXEC_LEVEL_MIN} AND ${level} LESS_EQUAL ${PHARE_EXEC_LEVEL_MAX}) - add_test(NAME ${target} COMMAND ${exe} WORKING_DIRECTORY ${directory}) - endif() - endfunction(phare_exec) - # use - # phare_exec(1 test_id ./binary ${CMAKE_CURRENT_BINARY_DIR}) - - function(phare_python3_exec level target file directory) - if(${level} GREATER_EQUAL ${PHARE_EXEC_LEVEL_MIN} AND ${level} LESS_EQUAL ${PHARE_EXEC_LEVEL_MAX}) - string (REPLACE ";" " " CLI_ARGS "${ARGN}") - add_test(NAME py3_${target} COMMAND python3 -u ${file} ${CLI_ARGS} WORKING_DIRECTORY ${directory}) - set_exe_paths_(py3_${target}) - endif() - endfunction(phare_python3_exec) - # use - # phare_python3_exec(1 test_id script.py ${CMAKE_CURRENT_BINARY_DIR} $ARGS) - - - function(phare_mpi_python3_exec level N target file directory) - if(${level} GREATER_EQUAL ${PHARE_EXEC_LEVEL_MIN} AND ${level} LESS_EQUAL ${PHARE_EXEC_LEVEL_MAX}) - string (REPLACE ";" " " CLI_ARGS "${ARGN}") - if(${N} EQUAL 1) - add_test( - NAME py3_${target} - COMMAND python3 -u ${file} ${CLI_ARGS} - WORKING_DIRECTORY ${directory}) - set_exe_paths_(py3_${target}) - else() - add_test( - NAME py3_${target}_mpi_n_${N} - COMMAND mpirun -n ${N} python3 -u ${file} ${CLI_ARGS} - WORKING_DIRECTORY ${directory}) - set_exe_paths_(py3_${target}_mpi_n_${N}) - endif() - endif() - endfunction(phare_mpi_python3_exec) - # use - # phare_mpi_python3_exec(1 2 test_id script.py ${CMAKE_CURRENT_BINARY_DIR} $ARGS) - - set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} ${PHARE_PROJECT_DIR}) - - enable_testing() - configure_file(${CMAKE_SOURCE_DIR}/tests/__init__.py ${CMAKE_BINARY_DIR}/tests/__init__.py @ONLY) diff --git a/tests/amr/data/field/coarsening/CMakeLists.txt b/tests/amr/data/field/coarsening/CMakeLists.txt index 4e3dd7774..c73804e24 100644 --- a/tests/amr/data/field/coarsening/CMakeLists.txt +++ b/tests/amr/data/field/coarsening/CMakeLists.txt @@ -30,11 +30,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE phare_amr ${GTEST_LIBS}) - -add_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_command(TARGET ${PROJECT_NAME} - POST_BUILD + PRE_BUILD COMMAND "PYTHONPATH=${CMAKE_BINARY_DIR}:${PHARE_PYTHONPATH}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_coarsen_field.py ${CMAKE_CURRENT_BINARY_DIR}) - +add_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/amr/multiphysics_integrator/CMakeLists.txt b/tests/amr/multiphysics_integrator/CMakeLists.txt index 810e5f5ec..ec732ec7b 100644 --- a/tests/amr/multiphysics_integrator/CMakeLists.txt +++ b/tests/amr/multiphysics_integrator/CMakeLists.txt @@ -11,6 +11,7 @@ set(SOURCES_CPP add_executable(${PROJECT_NAME} ${SOURCES_INC} ${SOURCES_CPP}) +add_dependencies(${PROJECT_NAME} cpp_etc) target_include_directories(${PROJECT_NAME} PRIVATE $ diff --git a/tests/core/data/gridlayout/CMakeLists.txt b/tests/core/data/gridlayout/CMakeLists.txt index 748f814e5..c5d8aba4f 100644 --- a/tests/core/data/gridlayout/CMakeLists.txt +++ b/tests/core/data/gridlayout/CMakeLists.txt @@ -40,13 +40,13 @@ target_link_libraries(${PROJECT_NAME} PRIVATE phare_core ${GTEST_LIBS}) -add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_command(TARGET ${PROJECT_NAME} - POST_BUILD + PRE_BUILD COMMAND "PYTHONPATH=${PHARE_PYTHONPATH}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gridlayout_generate_test_files.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) + if(NOT ${PHARE_PROJECT_DIR} STREQUAL ${CMAKE_BINARY_DIR}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/grid_yee.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endif() diff --git a/tests/core/numerics/ampere/CMakeLists.txt b/tests/core/numerics/ampere/CMakeLists.txt index ca3ba4960..79bf7511d 100644 --- a/tests/core/numerics/ampere/CMakeLists.txt +++ b/tests/core/numerics/ampere/CMakeLists.txt @@ -14,9 +14,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE phare_core ${GTEST_LIBS}) -add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) add_custom_command(TARGET test-ampere - POST_BUILD + PRE_BUILD COMMAND "PYTHONPATH=${PHARE_PYTHONPATH}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_ampere.py ${CMAKE_CURRENT_BINARY_DIR}) - +add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/core/numerics/faraday/CMakeLists.txt b/tests/core/numerics/faraday/CMakeLists.txt index 9e63af118..349fdaba8 100644 --- a/tests/core/numerics/faraday/CMakeLists.txt +++ b/tests/core/numerics/faraday/CMakeLists.txt @@ -14,8 +14,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE phare_core ${GTEST_LIBS}) -add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) add_custom_command(TARGET test-faraday - POST_BUILD + PRE_BUILD COMMAND "PYTHONPATH=${PHARE_PYTHONPATH}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_faraday.py ${CMAKE_CURRENT_BINARY_DIR}) +add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/core/numerics/interpolator/CMakeLists.txt b/tests/core/numerics/interpolator/CMakeLists.txt index bb3102171..0342a3f8c 100644 --- a/tests/core/numerics/interpolator/CMakeLists.txt +++ b/tests/core/numerics/interpolator/CMakeLists.txt @@ -14,11 +14,12 @@ target_link_libraries(${PROJECT_NAME} PRIVATE phare_core ${GTEST_LIBS}) -add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) add_custom_command(TARGET test-interpolator - POST_BUILD + PRE_BUILD COMMAND "PYTHONPATH=${PHARE_PYTHONPATH}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/interpolator_test.py ${CMAKE_CURRENT_BINARY_DIR}) +add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) + if(NOT ${PHARE_PROJECT_DIR} STREQUAL ${CMAKE_BINARY_DIR}) file(GLOB PYFILES "*.py") diff --git a/tests/core/numerics/ohm/CMakeLists.txt b/tests/core/numerics/ohm/CMakeLists.txt index 5710f7a00..28767de89 100644 --- a/tests/core/numerics/ohm/CMakeLists.txt +++ b/tests/core/numerics/ohm/CMakeLists.txt @@ -14,9 +14,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE phare_core ${GTEST_LIBS}) -add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) add_custom_command(TARGET test-ohm - POST_BUILD + PRE_BUILD COMMAND "PYTHONPATH=${PHARE_PYTHONPATH}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_ohm.py ${CMAKE_CURRENT_BINARY_DIR}) - +add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/core/numerics/pusher/CMakeLists.txt b/tests/core/numerics/pusher/CMakeLists.txt index 25ed2f1a6..afe64a90b 100644 --- a/tests/core/numerics/pusher/CMakeLists.txt +++ b/tests/core/numerics/pusher/CMakeLists.txt @@ -14,9 +14,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE phare_core ${GTEST_LIBS}) -add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) add_custom_command(TARGET test-pusher - POST_BUILD + PRE_BUILD COMMAND "PYTHONPATH=${PHARE_PYTHONPATH}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_pusher.py ${CMAKE_CURRENT_BINARY_DIR}) - +add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/diagnostic/CMakeLists.txt b/tests/diagnostic/CMakeLists.txt index 6fa3d329e..3a5964a5f 100644 --- a/tests/diagnostic/CMakeLists.txt +++ b/tests/diagnostic/CMakeLists.txt @@ -26,6 +26,8 @@ if(HighFive) ${GTEST_LIBS} ${HDF5_LIBRARIES}) + add_dependencies(${src_name} cpp_etc) + add_phare_test(${src_name} ${CMAKE_CURRENT_BINARY_DIR}) endfunction(_add_diagnostics_test) diff --git a/tests/initializer/CMakeLists.txt b/tests/initializer/CMakeLists.txt index 96a4e61b7..08954102d 100644 --- a/tests/initializer/CMakeLists.txt +++ b/tests/initializer/CMakeLists.txt @@ -17,6 +17,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE configure_file(${CMAKE_CURRENT_SOURCE_DIR}/job.py ${CMAKE_CURRENT_BINARY_DIR}/job.py @ONLY) +add_dependencies(${PROJECT_NAME} cpp_etc) + add_no_mpi_phare_test(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR})