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
Install tests/tests.h #13033
Install tests/tests.h #13033
Conversation
Are we ready to guarantee backward compatibility of this file? Separately, though, this file has this line:
I am against having this in any installed file. |
I am slightly against doing this. If there is functionality in it that people are using (and we want to export) we should just move these things somewhere else. We don't expose any other part of the test suite in an installation AFAICT (and we should not IMHO). |
It sure is useful for auxiliary projects like ours to be able to use this file. However, keeping a copy is not really troublesome either... |
CMakeLists.txt
Outdated
CONFIGURE_FILE( | ||
${CMAKE_CURRENT_SOURCE_DIR}/tests/tests.h | ||
${CMAKE_CURRENT_BINARY_DIR}/include/deal.II/tests/tests.h | ||
) | ||
ENDIF() |
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 am worried about this conditional: DEAL_II_HAVE_TESTS_DIRECTORY
is false when the tests
directory is not present. If you happen to now build and install deal.II without the tests directory you will end up not installing this header file and potentially break downstream projects.
What about we identify the useful and stable part of this header and simply migrate it to includes
?
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 can live with that as long as I don't have too see another project that simply copies the test.h
file because they want to use the deal.II test infrastructure but crucial functions are missing.
include/deal.II/tests/tests.h
Outdated
// | ||
//--------------------------------------------------------------- | ||
|
||
#ifndef dealii_tests_h |
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 have move the classes related to logging into the new file. We can add additional functions here depending on the feedback of users.
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.
@peterrum: I think in addition the header <fstream>
and the definition void cat_file(const char *filename)
need to be moved into this file. Otherwise, one gets a build error as cat_file
is called in struct MPILogInitAll
.
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.
Thanks for the feedback! I'll add it!
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'm still not entirely convinced that putting things into the library is the right thing to do. Among the reasons is that application programs or tutorials will not use these things -- it's just stuff that's used for testing, and so my take is that it should be part of the testing infrastructure, not the library proper. But if the majority is in favor, I'm also not going to stand in the way.
Regardless, things will have to move out of the dealii
namespace. Put them into a nested namespace instead, and then you can put a using namespace ...
declaration into tests/tests.h
.
include/deal.II/tests/tests.h
Outdated
// switch off screen output. If screen output is desired, provide the | ||
// optional first argument as 'true'. | ||
std::string deallogname; | ||
std::ofstream deallogfile; |
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.
This is putting things into the global dealii
namespace that I don't think should be there. If you must, we could have a nested namespace dealii::Testing
where all of this could go.
edf0577
to
19fd2b1
Compare
What do we do with this? I continue to think that installing |
Let me again explain the motivation for this PR. We already allow users to use our testing infrastructure in their own projects, most notably with |
FWIW, I don't copy the ##
# Configure the test / benchmark environment
##
IF(BUILD_TESTS OR BUILD_BENCHMARKS)
MESSAGE(STATUS "CTest environment enabled")
ENABLE_TESTING()
INCLUDE(CTest)
FIND_FILE(DEAL_II_TESTS_H tests.h
HINTS ${deal.II_SOURCE_DIR}/tests ${DEAL_II_SOURCE_DIR} $ENV{DEAL_II_SOURCE_DIR}
PATH_SUFFIXES tests
NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
)
IF(EXISTS ${DEAL_II_TESTS_H})
MESSAGE(STATUS "Path to deal.II test header: ${DEAL_II_TESTS_H}")
ELSE()
MESSAGE(STATUS "Tests could not be enabled: deal.II's test.h file could not be found.")
ENDIF()
IF(BUILD_TESTS AND EXISTS ${DEAL_II_TESTS_H})
MESSAGE(STATUS "Tests enabled")
INCLUDE_DIRECTORIES(${DEAL_II_SOURCE_DIR}/tests)
ADD_SUBDIRECTORY(tests)
ENDIF()
IF(BUILD_BENCHMARKS AND EXISTS ${DEAL_II_TESTS_H})
IF(${CMAKE_BUILD_TYPE} MATCHES "Release")
MESSAGE(STATUS "Benchmarks enabled")
# Set the time limit for the benchmark tests
MATH(EXPR CUSTOM_TEST_TIME_LIMIT "24 * 60 * 60") # Seconds
SET(TEST_TIME_LIMIT ${CUSTOM_TEST_TIME_LIMIT})
INCLUDE_DIRECTORIES(${DEAL_II_SOURCE_DIR}/tests)
ADD_SUBDIRECTORY(benchmarks)
ELSE()
MESSAGE(STATUS "Benchmarks disabled when not in release mode")
ENDIF()
ENDIF()
ENDIF() |
I think my concern is mostly that It's also not quite clear which parts a user project would actually want to use. I mean, is anyone going to use I'm not saying that there isn't useful stuff that would make for a good starting point for user |
Let me close this PR! The opposition is too large. I went with a modified of @jppelteret's suggestion. Thanks! |
Many projects create a copy of this file. Why don't we simply install the file so that it can be accessed via
#include <deal.II/tests/tests.h>
?FYI @slfuchs @blaisb