use canonical syntax for adding tests

This commit is contained in:
Axel Kohlmeyer 2022-01-28 21:12:13 -05:00
parent 5c0c3df035
commit 7978bf671d
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
5 changed files with 21 additions and 25 deletions

View File

@ -1,26 +1,26 @@
add_executable(test_library_open test_library_open.cpp test_main.cpp)
target_link_libraries(test_library_open PRIVATE lammps GTest::GMock)
add_test(LibraryOpen test_library_open)
add_test(NAME LibraryOpen COMMAND test_library_open WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_library_commands test_library_commands.cpp test_main.cpp)
target_link_libraries(test_library_commands PRIVATE lammps GTest::GMock)
add_test(LibraryCommands test_library_commands)
add_test(NAME LibraryCommands COMMAND test_library_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_library_external test_library_external.cpp test_main.cpp)
target_link_libraries(test_library_external PRIVATE lammps GTest::GMock)
add_test(LibraryExternal test_library_external)
add_test(NAME LibraryExternal COMMAND test_library_external WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_library_properties test_library_properties.cpp test_main.cpp)
target_link_libraries(test_library_properties PRIVATE lammps GTest::GMock)
target_compile_definitions(test_library_properties PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
add_test(LibraryProperties test_library_properties)
add_test(NAME LibraryProperties COMMAND test_library_properties WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(LibraryProperties PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
add_executable(test_library_scatter_gather test_library_scatter_gather.cpp test_main.cpp)
target_link_libraries(test_library_scatter_gather PRIVATE lammps GTest::GMock)
target_compile_definitions(test_library_scatter_gather PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
add_test(LibraryScatterGather test_library_scatter_gather)
add_test(NAME LibraryScatterGather COMMAND test_library_scatter_gather WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(LibraryScatterGather PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
set(TEST_CONFIG_DEFS "-DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR};-DLAMMPS_${LAMMPS_SIZES}")
@ -65,9 +65,9 @@ endforeach()
add_executable(test_library_config test_library_config.cpp test_main.cpp)
target_link_libraries(test_library_config PRIVATE lammps GTest::GMock)
target_compile_definitions(test_library_config PRIVATE ${TEST_CONFIG_DEFS})
add_test(LibraryConfig test_library_config)
add_test(NAME LibraryConfig COMMAND test_library_config WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_library_mpi test_library_mpi.cpp)
target_link_libraries(test_library_mpi PRIVATE lammps GTest::GMock)
target_compile_definitions(test_library_mpi PRIVATE ${TEST_CONFIG_DEFS})
add_mpi_test(NAME LibraryMPI NUM_PROCS 4 COMMAND $<TARGET_FILE:test_library_mpi>)
add_mpi_test(NAME LibraryMPI NUM_PROCS 4 COMMAND $<TARGET_FILE:test_library_mpi> WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -1,13 +1,13 @@
add_executable(test_lammps_class test_lammps_class.cpp)
target_link_libraries(test_lammps_class PRIVATE lammps GTest::GMockMain)
add_test(LammpsClass test_lammps_class)
add_test(NAME LammpsClass COMMAND test_lammps_class WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(LammpsClass PROPERTIES ENVIRONMENT "OMP_NUM_THREADS=1")
add_executable(test_input_class test_input_class.cpp)
target_link_libraries(test_input_class PRIVATE lammps GTest::GTestMain)
add_test(InputClass test_input_class)
add_test(NAME InputClass COMMAND test_input_class WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_error_class test_error_class.cpp)
target_link_libraries(test_error_class PRIVATE lammps GTest::GMock)
add_test(ErrorClass test_error_class)
add_test(NAME ErrorClass COMMAND test_error_class WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -59,7 +59,7 @@ endif()
add_executable(test_error_stats test_error_stats.cpp)
target_include_directories(test_error_stats PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LAMMPS_SOURCE_DIR})
target_link_libraries(test_error_stats PRIVATE gtest_main)
add_test(NAME ErrorStats COMMAND test_error_stats)
add_test(NAME ErrorStats COMMAND test_error_stats WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# pair style tester
add_executable(test_pair_style test_pair_style.cpp)

View File

@ -26,11 +26,11 @@ if(CMAKE_Fortran_COMPILER)
add_executable(test_fortran_create wrap_create.cpp test_fortran_create.f90)
target_link_libraries(test_fortran_create PRIVATE flammps lammps MPI::MPI_Fortran GTest::GTestMain)
add_test(FortranOpen test_fortran_create)
add_test(NAME FortranOpen COMMAND test_fortran_create WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_fortran_commands wrap_commands.cpp test_fortran_commands.f90)
target_link_libraries(test_fortran_commands PRIVATE flammps lammps MPI::MPI_Fortran GTest::GTestMain)
add_test(FortranCommands test_fortran_commands)
add_test(NAME FortranCommands COMMAND test_fortran_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
message(STATUS "Skipping Tests for the LAMMPS Fortran Module: no Fortran compiler")
endif()

View File

@ -1,22 +1,23 @@
add_executable(test_tokenizer test_tokenizer.cpp)
target_link_libraries(test_tokenizer PRIVATE lammps GTest::GMockMain)
add_test(Tokenizer test_tokenizer)
add_test(NAME Tokenizer COMMAND test_tokenizer WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_mempool test_mempool.cpp)
target_link_libraries(test_mempool PRIVATE lammps GTest::GMockMain)
add_test(MemPool test_mempool)
add_test(NAME MemPool COMMAND test_mempool WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_argutils test_argutils.cpp)
target_link_libraries(test_argutils PRIVATE lammps GTest::GMockMain)
add_test(ArgUtils test_argutils)
add_test(NAME ArgUtils COMMAND test_argutils WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_utils test_utils.cpp)
target_link_libraries(test_utils PRIVATE lammps GTest::GMockMain)
add_test(Utils test_utils)
add_test(NAME Utils COMMAND test_utils WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_platform test_platform.cpp)
target_link_libraries(test_platform PRIVATE lammps GTest::GMockMain)
add_test(Platform test_platform)
add_test(NAME Platform COMMAND test_platform WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(Utils Platform PROPERTIES
ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
@ -35,13 +36,8 @@ endif()
add_executable(test_fmtlib test_fmtlib.cpp)
target_link_libraries(test_fmtlib PRIVATE lammps GTest::GMockMain)
add_test(FmtLib test_fmtlib)
add_test(NAME FmtLib COMMAND test_fmtlib WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_math_eigen_impl test_math_eigen_impl.cpp)
target_include_directories(test_math_eigen_impl PRIVATE ${LAMMPS_SOURCE_DIR})
add_test(MathEigen test_math_eigen_impl 10 5)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_tests_properties(Tokenizer MemPool ArgUtils Utils Platform FmtLib MathEigen PROPERTIES
ENVIRONMENT "PATH=${CMAKE_BINARY_DIR}:$ENV{PATH}")
endif()
add_test(NAME MathEigen COMMAND test_math_eigen_impl 10 5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})