Skip to content

Commit

Permalink
simplify testing conditions, remove RF_ENABLE_TESTING in favour of BU…
Browse files Browse the repository at this point in the history
…ILD_TESTING
  • Loading branch information
Ylannl committed Jun 2, 2024
1 parent 0d52eac commit f263d38
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 45 deletions.
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ cmake_minimum_required(VERSION 3.25)
# TODO: add version number
project(roofer LANGUAGES C CXX)

# Options
option(RF_USE_LOGGER_SPDLOG "Whether to use spdlog as logging backend." OFF)
option(RF_USE_RERUN "Enable features dependent on Rerun" OFF)
option(RF_USE_VAL3DITY "Enable features dependent on Val3dity" OFF)
option(RF_BUILD_APPS "Build applications in addition to library" ON)
option(BUILD_SHARED_LIBS "Build using shared libraries (may not work)" OFF)
option(BUILD_TESTING "Enable tests" OFF)
include(CTest)

# Global CMake variables are set here We use C++20, with the assumption that we
# only implement features that are supported by GCC, Clang, MSVC, Apple Clang
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Don't use extensions, because they might affect compiler compatibility
set(CMAKE_CXX_EXTENSIONS OFF)

# Options
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
option(RF_ENABLE_TESTING "Enable a Unit Testing build." OFF)
option(RF_USE_LOGGER_SPDLOG "Whether to use spdlog as logging backend." OFF)
option(RF_USE_RERUN "Enable features dependent on Rerun" OFF)
option(RF_USE_VAL3DITY "Enable features dependent on Val3dity" OFF)
option(RF_BUILD_APPS "Build applications in addition to library" ON)
# CMAKE MODULES

# CMake modules, like the documentation module, go in here
Expand Down Expand Up @@ -82,18 +84,15 @@ endif()
# e.g. version numbers and feature flags
set(ROOFER_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
add_subdirectory(src)
if(RF_ENABLE_TESTING)
include(CTest)
if(BUILD_TESTING)
include(FetchContent)
enable_testing()
# enable_testing()
# We use the apps in the integration tests, so we need to build them here
add_subdirectory(apps)
# add_subdirectory(apps)
add_subdirectory(tests)
endif()

# EXECUTABLES
if(BUILD_APPS)
if(NOT RF_ENABLE_TESTING)
add_subdirectory(apps)
endif()
if(RF_BUILD_APPS)
add_subdirectory(apps)
endif()
7 changes: 4 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"RF_USE_VAL3DITY": "OFF",
"RF_USE_RERUN": "OFF",
"RF_USE_LOGGER_SPDLOG": "OFF",
"RF_ENABLE_TESTING": "OFF",
"BUILD_TESTING": "OFF",
"RF_BUILD_APPS": "ON"
}
},
Expand All @@ -20,7 +20,8 @@
"description": "Build with vcpkg without any optional dependencies, in order to get the quickest build possible for running tests.",
"inherits": "vcpkg-minimal",
"cacheVariables": {
"RF_ENABLE_TESTING": "ON"
"BUILD_TESTING": "ON",
"RF_BUILD_APPS": "ON"
}
},
{
Expand All @@ -32,7 +33,7 @@
"RF_USE_VAL3DITY": "OFF",
"RF_USE_RERUN": "OFF",
"RF_USE_LOGGER_SPDLOG": "OFF",
"RF_ENABLE_TESTING": "ON",
"BUILD_TESTING": "ON",
"RF_BUILD_APPS": "ON"
}
},
Expand Down
2 changes: 1 addition & 1 deletion README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See the CMake presets for the available test configurations.
Various test cases are available at https://data.3dgi.xyz/roofer-test-data.
Each test case is documented in the README.

The test data is downloaded automatically into `tests/data` during the project configuration, provided that you enable the tests with `RF_ENABLE_TESTING`.
The test data is downloaded automatically into `tests/data` during the project configuration, provided that you enable the tests with `BUILD_TESTING`.
Once available locally, the data is not re-downloaded, unless the files are removed or they change on the server.

#### Adding test data
Expand Down
53 changes: 27 additions & 26 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,35 @@ FetchContent_Declare(
FetchContent_MakeAvailable(wippolder)

# Integration tests that are run on the built executables, before installation.
if(RF_BUILD_APPS)
add_test(
NAME "crop-wippolder"
COMMAND $<TARGET_FILE:crop> --config "${CONFIG_DIR}/crop-wippolder.toml"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

add_test(
NAME "crop-wippolder"
COMMAND $<TARGET_FILE:crop> --config "${CONFIG_DIR}/crop-wippolder.toml"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_test(
NAME "reconstruct-wippolder"
COMMAND
$<TARGET_FILE:reconstruct> --config
"${CONFIG_DIR}/reconstruct-wippolder.toml"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

add_test(
NAME "reconstruct-wippolder"
COMMAND
$<TARGET_FILE:reconstruct> --config
"${CONFIG_DIR}/reconstruct-wippolder.toml"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
set(tests_built "crop-wippolder;reconstruct-wippolder")
set_tests_properties(${tests_built} PROPERTIES ENVIRONMENT
"${TEST_ENVIRONMENT}")

set(tests_built "crop-wippolder;reconstruct-wippolder")
set_tests_properties(${tests_built} PROPERTIES ENVIRONMENT
"${TEST_ENVIRONMENT}")
# Integration tests that are run on the installed artifacts must be prefixed with
# "installed-". Note that these tests must be invoked *after* the artifacts were
# installed.
# We don't set the TEST_ENVIRONMENT for the installed apps, because the required
# paths are supposed to be set by the install process.

# Integration tests that are run on the installed artifacts must be prefixed with
# "installed-". Note that these tests must be invoked *after* the artifacts were
# installed.
# We don't set the TEST_ENVIRONMENT for the installed apps, because the required
# paths are supposed to be set by the install process.

add_test(
NAME "installed-apps"
COMMAND pytest -k TestApps
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
if(WIN32)
set_tests_properties("installed-apps" PROPERTIES ENVIRONMENT
"PROJ_DATA=${CMAKE_INSTALL_PREFIX}\\share\\proj;GDAL_DATA=${CMAKE_INSTALL_PREFIX}\\share\\gdal;PATH=C:\\Program Files (x86)\\roofer\\bin\;$ENV{PATH}")
add_test(
NAME "installed-apps"
COMMAND pytest -k TestApps
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
if(WIN32)
set_tests_properties("installed-apps" PROPERTIES ENVIRONMENT
"PROJ_DATA=${CMAKE_INSTALL_PREFIX}\\share\\proj;GDAL_DATA=${CMAKE_INSTALL_PREFIX}\\share\\gdal;PATH=C:\\Program Files (x86)\\roofer\\bin\;$ENV{PATH}")
endif()
endif()

0 comments on commit f263d38

Please sign in to comment.