Skip to content

Commit

Permalink
[WIP] Add packaging tests
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed Feb 23, 2024
1 parent 4dc8097 commit e0820df
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test-suite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ endforeach ()
add_subdirectory(tests)
## Add functional tests
add_subdirectory(libv2-demo)
## Add packaging tests
add_subdirectory(package)
15 changes: 15 additions & 0 deletions test-suite/package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set_property(DIRECTORY APPEND
PROPERTY LABELS package
)

set(test_list
FetchContent
find_package
)
if (NOT Wannier90_IS_TOP_LEVEL)
list(APPEND test_list pkg-config)
endif ()

foreach (test IN LISTS test_list)
Wannier90_add_test(${test} TEST_NAME test-${test})
endforeach ()
39 changes: 39 additions & 0 deletions test-suite/package/FetchContent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.25...3.29)
project(example_Wannier90 LANGUAGES Fortran)


include(FetchContent)

if (DEFINED ENV{PACKIT_SOURCE_URL})
set(git_repo $ENV{PACKIT_SOURCE_URL})
else ()
set(git_repo https://github.com/wannier-developers/wannier90)
endif ()
if (DEFINED ENV{PACKIT_SOURCE_SHA})
set(git_tag $ENV{PACKIT_SOURCE_SHA})
elseif (DEFINED ENV{PACKIT_COMMIT_SHA})
set(git_tag $ENV{PACKIT_COMMIT_SHA})
else ()
set(git_tag develop)
endif ()

FetchContent_Declare(Wannier90
GIT_REPOSITORY ${git_repo}
GIT_TAG ${git_tag}
)
FetchContent_MakeAvailable(Wannier90)

add_executable(main src/main.F90)
target_link_libraries(main PRIVATE Wannier90::wannier90)

enable_testing()

add_test(NAME smoke_test_lib
COMMAND $<TARGET_FILE:main>
)
add_test(NAME smoke_test_exe
COMMAND $<TARGET_FILE:Wannier90::exe> --version
)
add_test(NAME smoke_test_post
COMMAND $<TARGET_FILE:Wannier90::post> --version
)
1 change: 1 addition & 0 deletions test-suite/package/FetchContent/src
19 changes: 19 additions & 0 deletions test-suite/package/find_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.25...3.29)
project(example_Wannier90 LANGUAGES Fortran)

find_package(Wannier90 REQUIRED)

add_executable(main src/main.F90)
target_link_libraries(main PRIVATE Wannier90::wannier90)

enable_testing()

add_test(NAME smoke_test_lib
COMMAND $<TARGET_FILE:main>
)
add_test(NAME smoke_test_exe
COMMAND $<TARGET_FILE:Wannier90::exe> --version
)
add_test(NAME smoke_test_post
COMMAND $<TARGET_FILE:Wannier90::post> --version
)
1 change: 1 addition & 0 deletions test-suite/package/find_package/src
14 changes: 14 additions & 0 deletions test-suite/package/pkg-config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.25...3.29)
project(example_Wannier90 LANGUAGES Fortran)

find_package(PkgConfig REQUIRED)
pkg_check_modules(Wannier90 REQUIRED IMPORTED_TARGET wannier90)

add_executable(main src/main.F90)
target_link_libraries(main PRIVATE PkgConfig::Wannier90)

enable_testing()

add_test(NAME smoke_test_lib
COMMAND $<TARGET_FILE:main>
)
1 change: 1 addition & 0 deletions test-suite/package/pkg-config/src
6 changes: 6 additions & 0 deletions test-suite/package/src/main.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
program wannier90_example
use w90_library
implicit none

! TODO: Implement basic smoke test
end program wannier90_example

0 comments on commit e0820df

Please sign in to comment.