diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 12d7b39dd..dc1bdbc96 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,13 +1,16 @@ +macro(ADDTEST name) + add_executable(test_${name} test_${name}.f90) + target_link_libraries(test_${name} fortran_stdlib) + add_test(NAME ${name} + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +endmacro(ADDTEST) + add_subdirectory(ascii) add_subdirectory(io) add_subdirectory(optval) -add_executable(test_skip test_skip.f90) -target_link_libraries(test_skip fortran_stdlib) -add_test(NAME AlwaysSkip COMMAND $) -set_tests_properties(AlwaysSkip PROPERTIES SKIP_RETURN_CODE 77) - -add_executable(test_fail test_fail.f90) -target_link_libraries(test_fail fortran_stdlib) -add_test(NAME AlwaysFail COMMAND $) -set_tests_properties(AlwaysFail PROPERTIES WILL_FAIL true) +ADDTEST(always_skip) +set_tests_properties(always_skip PROPERTIES SKIP_RETURN_CODE 77) +ADDTEST(always_fail) +set_tests_properties(always_fail PROPERTIES WILL_FAIL true) diff --git a/src/tests/ascii/CMakeLists.txt b/src/tests/ascii/CMakeLists.txt index 87b75cfaf..ed3356670 100644 --- a/src/tests/ascii/CMakeLists.txt +++ b/src/tests/ascii/CMakeLists.txt @@ -1,4 +1 @@ -add_executable(test_ascii test_ascii.f90) -target_link_libraries(test_ascii fortran_stdlib) - -add_test(NAME ASCII COMMAND $) +ADDTEST(ascii) diff --git a/src/tests/io/CMakeLists.txt b/src/tests/io/CMakeLists.txt index 42bb048c6..68388a5e5 100644 --- a/src/tests/io/CMakeLists.txt +++ b/src/tests/io/CMakeLists.txt @@ -1,33 +1,10 @@ -add_executable(test_loadtxt test_loadtxt.f90) -target_link_libraries(test_loadtxt fortran_stdlib) - -add_executable(test_savetxt test_savetxt.f90) -target_link_libraries(test_savetxt fortran_stdlib) - -add_executable(test_loadtxt_qp test_loadtxt_qp.f90) -target_link_libraries(test_loadtxt_qp fortran_stdlib) - -add_executable(test_savetxt_qp test_savetxt_qp.f90) -target_link_libraries(test_savetxt_qp fortran_stdlib) - -add_executable(test_open test_open.f90) -target_link_libraries(test_open fortran_stdlib) - -add_executable(test_parse_mode test_parse_mode.f90) -target_link_libraries(test_parse_mode fortran_stdlib) - -add_test(NAME loadtxt COMMAND $ ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_test(NAME savetxt COMMAND $ ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_test(NAME loadtxt_qp COMMAND $ ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_test(NAME savetxt_qp COMMAND $ ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_test(NAME open COMMAND $ ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_test(NAME parse_mode COMMAND $ ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +ADDTEST(loadtxt) +ADDTEST(savetxt) +ADDTEST(loadtxt_qp) +ADDTEST(savetxt_qp) set_tests_properties(loadtxt_qp PROPERTIES LABELS quadruple_precision) set_tests_properties(savetxt_qp PROPERTIES LABELS quadruple_precision) + +ADDTEST(open) +ADDTEST(parse_mode) diff --git a/src/tests/optval/CMakeLists.txt b/src/tests/optval/CMakeLists.txt index 5d6ae159e..19193fe1e 100644 --- a/src/tests/optval/CMakeLists.txt +++ b/src/tests/optval/CMakeLists.txt @@ -1,4 +1 @@ -add_executable(test_optval test_optval.f90) -target_link_libraries(test_optval fortran_stdlib) - -add_test(NAME OPTVAL COMMAND $) +ADDTEST(optval) diff --git a/src/tests/test_fail.f90 b/src/tests/test_always_fail.f90 similarity index 79% rename from src/tests/test_fail.f90 rename to src/tests/test_always_fail.f90 index 4803157d6..48ab13ed1 100644 --- a/src/tests/test_fail.f90 +++ b/src/tests/test_always_fail.f90 @@ -1,4 +1,4 @@ -program AlwaysFail +program test_always_fail use stdlib_experimental_error, only : assert implicit none diff --git a/src/tests/test_skip.f90 b/src/tests/test_always_skip.f90 similarity index 79% rename from src/tests/test_skip.f90 rename to src/tests/test_always_skip.f90 index 3fa6b1be3..84092d2fc 100644 --- a/src/tests/test_skip.f90 +++ b/src/tests/test_always_skip.f90 @@ -1,4 +1,4 @@ -program AlwaysSkip +program test_always_skip use stdlib_experimental_error, only : assert implicit none