-
Notifications
You must be signed in to change notification settings - Fork 73
add post-installation test (answer issue #2361) #2362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| I place my contributions to t8code under the FreeBSD license. Michele Martone <michelemartone@users.sourceforge.net> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # This file is part of t8code. | ||
| # t8code is a C library to manage a collection (a forest) of multiple | ||
| # connected adaptive space-trees of general element types in parallel. | ||
| # | ||
| # Copyright (C) 2026 the developers | ||
| # | ||
| # t8code is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 2 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # t8code is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with t8code; if not, write to the Free Software Foundation, Inc., | ||
| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
|
||
| cmake_minimum_required( VERSION 3.2 ) | ||
| project( | ||
| T8CODE_DOC_CMAKE_EXAMPLES | ||
| DESCRIPTION "A CMakeLists.txt file to test installed CMakeLists.txt example files (which can be ran independently anyways). The idea is to use this after installing T8CODE." | ||
| ) | ||
|
|
||
| # The two following lines stem from the user-provided installation directories. | ||
| # You can test the subdirectories individually by specifying them yourself via -D... | ||
| set(T8TEST_ROOT @CMAKE_INSTALL_PREFIX@) | ||
| set(CMAKE_PREFIX_PATH @CMAKE_INSTALL_PREFIX@) | ||
|
|
||
| file(GLOB T8CODE_CMAKE_EXAMPLES RELATIVE "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_CURRENT_LIST_DIR}/?") # for each single-character directory; notice there's no explicit listing here | ||
| add_custom_target(tests) | ||
| foreach(_dir IN LISTS T8CODE_CMAKE_EXAMPLES) | ||
| add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/${_dir} ) | ||
| add_dependencies( tests tests_${_dir} ) | ||
| endforeach() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # This file is part of t8code. | ||
| # t8code is a C library to manage a collection (a forest) of multiple | ||
| # connected adaptive space-trees of general element types in parallel. | ||
| # | ||
| # Copyright (C) 2026 the developers | ||
| # | ||
| # t8code is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 2 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # t8code is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with t8code; if not, write to the Free Software Foundation, Inc., | ||
| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
|
||
| # A CMakeLists.txt example file showing a way of detecting an installed instance of T8CODE and using it in program test.cxx. | ||
| # This example relies on what is being declared in files installed by T8CODE. | ||
|
|
||
| cmake_minimum_required(VERSION 3.22.0) | ||
| project(t8test DESCRIPTION "t8code test program (requires CMAKE_PREFIX_PATH to point to T8CODE's package files are)" LANGUAGES CXX) | ||
| find_package(T8CODE) | ||
| add_executable(test_a test.cxx) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please avoid using single letter file names, variable names, etc.? |
||
| target_link_libraries(test_a PRIVATE T8CODE::T8) | ||
| add_custom_target(tests_a COMMAND ./test_a) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # This file is part of t8code. | ||
| # t8code is a C library to manage a collection (a forest) of multiple | ||
| # connected adaptive space-trees of general element types in parallel. | ||
| # | ||
| # Copyright (C) 2026 the developers | ||
| # | ||
| # t8code is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 2 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # t8code is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with t8code; if not, write to the Free Software Foundation, Inc., | ||
| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
|
||
| # A CMakeLists.txt file showing a way of detecting an installed instance of T8CODE for use in program test.cxx. | ||
| # This example does not rely on what is being declared in files installed by T8CODE. | ||
|
|
||
| cmake_minimum_required(VERSION 3.22) | ||
| include(CheckIncludeFileCXX) | ||
| include(CheckLibraryExists) | ||
| project(t8test DESCRIPTION "t8code test program (needs T8TEST_ROOT to contain relevant include and lib directories and CMAKE_PREFIX_PATH to point to T8CODE's package files are.)" LANGUAGES CXX) | ||
| option(T8TEST_ROOT "Custom directory containing t8code's include, lib, ..." "") | ||
| find_library(T8CODE_LIBRARY t8 REQUIRED) # one may have done this in the if conditional construct after check_library_exists | ||
| CHECK_LIBRARY_EXISTS(t8 t8_init "${T8TEST_ROOT}/lib" HAVE_T8) # check_library_exists looks for a library and sets one variable accordingly | ||
| if(NOT HAVE_T8) | ||
| message(FATAL_ERROR "no t8 library found!") | ||
| else() | ||
| message("t8 library found in ${T8TEST_ROOT}/lib") | ||
| endif() | ||
| find_path(SC_INCLUDE_DIR sc.h REQUIRED) | ||
| find_path(T8CODE_INCLUDE_DIR t8.h REQUIRED) | ||
| add_executable(test_b test.cxx) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be good to have the directories under
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about |
||
| target_include_directories(test_b PUBLIC "${SC_INCLUDE_DIR}" ) | ||
| target_include_directories(test_b PUBLIC "${T8CODE_INCLUDE_DIR}" ) | ||
| target_link_directories(test_b PUBLIC "${T8TEST_ROOT}/lib" ) | ||
| target_link_libraries(test_b PRIVATE t8 sc) | ||
| add_custom_target(tests_b COMMAND ./test_b) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ function( add_t8_tutorial ) | |
| endif( T8CODE_EXPORT_COMPILE_COMMANDS ) | ||
|
|
||
| install( TARGETS ${ADD_T8_TUTORIAL_NAME} RUNTIME ) | ||
| install( FILES ${ADD_T8_TUTORIAL_SOURCES} DESTINATION ${CMAKE_INSTALL_DOCDIR}/tutorials/general/ ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please add a new configuration argument to do this and place this in its own cmake file inside the test folder? We want to keep all directories true to their purpose and the tutorial folder is just for tutorials. Same for the documentation folder.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you suggesting a new configuration variable?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think he meant that it should not be installed in ${ADD_T8_TUTORIAL_SOURCES}.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I meant that this is a post installation test and that it does not have anything to do with the tutorials. Yes, it uses a tutorial source file as test subject, but as a user i would not expect a post installation test in the tutorial folder. I would expect this to be in the test folder. Also, I would not expect this post installation test to be dependent on the |
||
| endfunction() | ||
|
|
||
| function( add_mesh_handle_tutorial ) | ||
|
|
@@ -81,6 +82,15 @@ copy_tutorial_file (features/t8_features_curved_meshes_generate_cmesh_quad.geo) | |
| copy_tutorial_file (features/t8_features_curved_meshes_generate_cmesh_tet.geo) | ||
| copy_tutorial_file (features/t8_features_curved_meshes_generate_cmesh_tri.geo) | ||
|
|
||
| # notice that in the following, we install files from doc/ and tutorials/ together: | ||
| file(GLOB T8CODE_CMAKE_EXAMPLES RELATIVE "${PROJECT_SOURCE_DIR}/doc/cmake_examples/" "${PROJECT_SOURCE_DIR}/doc/cmake_examples/?") # for each single-character directory; notice there's no explicit listing here | ||
| configure_file( ${PROJECT_SOURCE_DIR}/doc/cmake_examples/CMakeLists.txt.in ${CMAKE_BINARY_DIR}/doc/cmake_examples/CMakeLists.txt @ONLY) | ||
| install(FILES ${CMAKE_BINARY_DIR}/doc/cmake_examples/CMakeLists.txt DESTINATION ${CMAKE_INSTALL_DOCDIR}/cmake_examples/ RENAME CMakeLists.txt) # reminder that we may want to name this differently (yet, no necessity for .in) | ||
| foreach(_dir IN LISTS T8CODE_CMAKE_EXAMPLES) | ||
| install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/cmake_examples/${_dir} DESTINATION ${CMAKE_INSTALL_DOCDIR}/cmake_examples/) # notice we take directories from doc... | ||
| install(FILES ${PROJECT_SOURCE_DIR}/tutorials/general/t8_step0_helloworld.cxx DESTINATION ${CMAKE_INSTALL_DOCDIR}/cmake_examples/${_dir}/ RENAME test.cxx) #... and add the same sample tutorial program as a test | ||
| endforeach() | ||
|
Comment on lines
+85
to
+92
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can happily re-use the tutorial files as test source code, but the actual testing should stay outside the tutorial folder
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand your comment. Testing happens anyway in a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant, that the main purpose of this whole PR is to introduce a software test. Therefore, everything should be located in the |
||
|
|
||
| if( T8CODE_BUILD_MESH_HANDLE ) | ||
| add_mesh_handle_tutorial( NAME t8_mesh_element_data SOURCES mesh_handle/t8_mesh_element_data.cxx ) | ||
| endif() | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to translate this to cmake commands as good as possible. This way cmake peserves the used generator, build type, etc. and it is also OS agnostic.
The
BINARY_DIRcould be extracted from the (PROJECT_BINARY_DIR)[PROJECT_BINARY_DIR] cmake variable and passed to the test in the CMakeLists calling this build script.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed the
post_install_teststarget along the way. We want to have that.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I added it back