From c7abc3d8010fce43d415b7de1b1cc52d53c25087 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 22 Feb 2024 15:08:31 +0100 Subject: [PATCH] [WIP] Add packaging tests Signed-off-by: Cristian Le --- test-suite/CMakeLists.txt | 2 + test-suite/package/CMakeLists.txt | 15 +++++++ .../package/FetchContent/CMakeLists.txt | 39 +++++++++++++++++++ test-suite/package/FetchContent/src | 1 + .../package/find_package/CMakeLists.txt | 19 +++++++++ test-suite/package/find_package/src | 1 + test-suite/package/pkg-config/CMakeLists.txt | 14 +++++++ test-suite/package/pkg-config/src | 1 + test-suite/package/src/main.F90 | 6 +++ 9 files changed, 98 insertions(+) create mode 100644 test-suite/package/CMakeLists.txt create mode 100644 test-suite/package/FetchContent/CMakeLists.txt create mode 120000 test-suite/package/FetchContent/src create mode 100644 test-suite/package/find_package/CMakeLists.txt create mode 120000 test-suite/package/find_package/src create mode 100644 test-suite/package/pkg-config/CMakeLists.txt create mode 120000 test-suite/package/pkg-config/src create mode 100644 test-suite/package/src/main.F90 diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index 2e0a2add..ffee17b6 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -130,3 +130,5 @@ endforeach () add_subdirectory(tests) ## Add functional tests add_subdirectory(libv2-demo) +## Add packaging tests +add_subdirectory(package) diff --git a/test-suite/package/CMakeLists.txt b/test-suite/package/CMakeLists.txt new file mode 100644 index 00000000..3bbc402c --- /dev/null +++ b/test-suite/package/CMakeLists.txt @@ -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 () diff --git a/test-suite/package/FetchContent/CMakeLists.txt b/test-suite/package/FetchContent/CMakeLists.txt new file mode 100644 index 00000000..1f064493 --- /dev/null +++ b/test-suite/package/FetchContent/CMakeLists.txt @@ -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 $ +) +add_test(NAME smoke_test_exe + COMMAND $ --version +) +add_test(NAME smoke_test_post + COMMAND $ --version +) diff --git a/test-suite/package/FetchContent/src b/test-suite/package/FetchContent/src new file mode 120000 index 00000000..e057607e --- /dev/null +++ b/test-suite/package/FetchContent/src @@ -0,0 +1 @@ +../src/ \ No newline at end of file diff --git a/test-suite/package/find_package/CMakeLists.txt b/test-suite/package/find_package/CMakeLists.txt new file mode 100644 index 00000000..f394c75f --- /dev/null +++ b/test-suite/package/find_package/CMakeLists.txt @@ -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 $ +) +add_test(NAME smoke_test_exe + COMMAND $ --version +) +add_test(NAME smoke_test_post + COMMAND $ --version +) diff --git a/test-suite/package/find_package/src b/test-suite/package/find_package/src new file mode 120000 index 00000000..e057607e --- /dev/null +++ b/test-suite/package/find_package/src @@ -0,0 +1 @@ +../src/ \ No newline at end of file diff --git a/test-suite/package/pkg-config/CMakeLists.txt b/test-suite/package/pkg-config/CMakeLists.txt new file mode 100644 index 00000000..ff7e896b --- /dev/null +++ b/test-suite/package/pkg-config/CMakeLists.txt @@ -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 $ +) diff --git a/test-suite/package/pkg-config/src b/test-suite/package/pkg-config/src new file mode 120000 index 00000000..e057607e --- /dev/null +++ b/test-suite/package/pkg-config/src @@ -0,0 +1 @@ +../src/ \ No newline at end of file diff --git a/test-suite/package/src/main.F90 b/test-suite/package/src/main.F90 new file mode 100644 index 00000000..0ac7fc86 --- /dev/null +++ b/test-suite/package/src/main.F90 @@ -0,0 +1,6 @@ +program wannier90_example + use w90_library + implicit none + + ! TODO: Implement basic smoke test +end program wannier90_example