Skip to content

Automated cmake test discovery - #52

Open
elv3rs wants to merge 25 commits into
fortuno-repos:mainfrom
elv3rs:discovery
Open

Automated cmake test discovery#52
elv3rs wants to merge 25 commits into
fortuno-repos:mainfrom
elv3rs:discovery

Conversation

@elv3rs

@elv3rs elv3rs commented Dec 15, 2025

Copy link
Copy Markdown

Adds a cmake function to query the built fortuno executable and individually register the found tests with ctest.
Supports both post build and pre-test discovery as well as multi configuration generators.

This makes individually registering tests as easy as:

cmake_minimum_required(VERSION 3.25)
project(TestProject LANGUAGES Fortran)

include(FetchContent)
FetchContent_Declare(
    Fortuno
    GIT_REPOSITORY "https://github.com/elv3rs/fortuno"
    GIT_TAG "discovery"
)
FetchContent_MakeAvailable(Fortuno)

enable_testing()

add_executable(testapp testapp.f90)
target_link_libraries(testapp PRIVATE Fortuno::fortuno_serial)

fortuno_discover_tests(testapp)

The fortuno_discover_tests() function is also available after find_package(Fortuno). I.e. if the user is able to link with Fortuno::fortuno..., they can also use fortuno_discover_tests() with no additional includes.

@elv3rs elv3rs changed the title fortuno_discover_tests(target) Automated cmake test discovery Jan 8, 2026
elv3rs added 6 commits January 8, 2026 18:42
- Removed --allow-empty-run
- Renamed --disable-strict-matching to --ignore-no-match
Copy FortunoDiscoverTests.cmake to the build tree.
This allows using find_package on the build tree too, as opposed to only on the install tree.
Omit array expression to avoid memory leak
Workaround:gfortran:14.1 (bug 116679)
- Should fix FetchContent not finding Fortuno.cmake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant