-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Cristian Le <[email protected]>
- Loading branch information
Showing
10 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# Basic tests | ||
add_test(NAME version | ||
COMMAND ${CMAKE_Fypp_COMPILER} --version) | ||
|
||
# Integration tests | ||
add_subdirectory(cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
function(Fypp_add_test test_dir) | ||
#[===[.md: | ||
# Fypp_add_test | ||
|
||
Internal function for adding Fypp cmake tests | ||
|
||
## Synopsis | ||
```cmake | ||
Main interface | ||
Fypp_add_test(<test_dir> | ||
[TEST_NAME <name>] | ||
[TEST_COMMAND <args> ...] | ||
[BUILD_OPTIONS <args> ...]) | ||
``` | ||
|
||
## Options | ||
`<test_dir>` | ||
Path to the test CMake project | ||
|
||
`TEST_NAME` [Default `<test_dir>`] | ||
Name of the test | ||
|
||
`TEST_COMMAND` | ||
Additional test commands passed to `ctest --test-command` | ||
|
||
`BUILD_OPTIONS` | ||
CMake configure options passed to the testing cmake | ||
|
||
## See also | ||
- <inv:cmake:std:label:build and test mode> | ||
|
||
]===] | ||
|
||
|
||
set(ARGS_Options | ||
) | ||
set(ARGS_OneValue | ||
TEST_NAME | ||
) | ||
set(ARGS_MultiValue | ||
BUILD_OPTIONS | ||
TEST_COMMAND | ||
) | ||
|
||
cmake_parse_arguments(PARSE_ARGV 1 ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}") | ||
|
||
# Resolve default options | ||
if (NOT DEFINED ARGS_TEST_NAME) | ||
set(ARGS_TEST_NAME ${test_dir}) | ||
endif () | ||
|
||
add_test(NAME ${ARGS_TEST_NAME} COMMAND ${CMAKE_CTEST_COMMAND} | ||
--build-and-test | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${test_dir} | ||
${CMAKE_CURRENT_BINARY_DIR}/${test_dir} | ||
--build-generator "${CMAKE_GENERATOR}" | ||
--build-options | ||
${ARGS_BUILD_OPTIONS} | ||
--test-command ${CMAKE_CTEST_COMMAND} --test-dir=${CMAKE_CURRENT_BINARY_DIR}/${test_dir} --no-tests=ignore ${ARGS_TEST_COMMAND} | ||
) | ||
endfunction() | ||
|
||
set(build_options) | ||
set(test_command) | ||
set(test_dir_rel) | ||
foreach (test_dir IN ITEMS | ||
module | ||
) | ||
block() | ||
cmake_path(APPEND test_dir_rel ${test_dir}) | ||
add_subdirectory(${test_dir}) | ||
endblock() | ||
endforeach () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
list(APPEND build_options | ||
"-DCMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake" | ||
) | ||
foreach (test IN ITEMS fypp) | ||
set(args) | ||
if (build_options) | ||
list(APPEND args BUILD_OPTIONS ${build_options}) | ||
endif () | ||
if (test_command) | ||
list(APPEND args TEST_COMMAND ${test_command}) | ||
endif () | ||
Fypp_add_test(${test_dir_rel}/${test} ${args}) | ||
endforeach () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(test_fypp LANGUAGES Fortran) | ||
include(Fypp) | ||
|
||
Fypp_add_executable(exec src/test_exec.fypp) | ||
#Fypp_add_library(test_obj OBJECT src/test_obj.fypp src/test_bare.f90) | ||
Fypp_add_library(test_static STATIC src/test_static.fypp) | ||
Fypp_add_library(test_shared SHARED src/test_shared.fypp) | ||
add_library(test_obj_other OBJECT) | ||
target_compile_definitions(test_obj_other PRIVATE FOO BAR=some_value) | ||
Fypp_target_sources(test_obj_other PRIVATE src/test_obj.fypp src/test_bare.f90) | ||
|
||
enable_testing() | ||
add_test(NAME test_exec COMMAND $<TARGET_FILE:exec>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module test_bare_m | ||
integer :: a | ||
end module test_bare_m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
program test | ||
print *, "hello" | ||
end program test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module test_obj_m | ||
integer :: a | ||
end module test_obj_m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module test_shared_m | ||
integer :: a | ||
end module test_shared_m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module test_static_m | ||
integer :: a | ||
end module test_static_m |