Skip to content

Draft: Build tests when 'make test'

Sergey Kosukhin requested to merge feature-delay-tests into master

It is a bit annoying that we have to configure the project with -DBUILD_TESTING=OFF in ICON and, therefore, cannot run the tests (make check for ICON is translated to make test for fortran-support, which essentially does nothing). The reason why we have to disable the test is that we don't want ICON users to fetch GTest and FortUTF every time the build the model (most of the users do not need to run the tests). We also don't want them to have to build what they don't need (i.e. the test executables). Additionally, building executables is sometimes more problematic on some platforms than building only the static libraries, which are needed for ICON. In contrast to Autoconf, building the test executables with make all (or just make) is the standard approach in CMake.

This is my attempt to make the building of the test executables and the fetching of the required libraries part of the test target. This way, GTest is fetched and the tests are built only when the user runs make test. Unfortunately, it is much more tricky to do that FortUTF because we need to run fortutf.cmake to declare the test executable. Therefore, I temporarily disabled the Fortran tests in the source branch of this MR to demonstrate the idea. I will need to solve this problem and probably polish the scripting for the GTest-based tests if we decide to go this way.

I am not sure yet if it's worth it at all but I did some experimenting and decided to show the results.

Merge request reports

Loading