Skip to content

Commit

Permalink
WIP: Add failing test for using TriBITS functions in a raw CMake pack…
Browse files Browse the repository at this point in the history
…age in TriBITS project (#582)

This test sets up to use the TriBITS test management functions from inside of
a raw CMake package under a TriBITS project.
  • Loading branch information
bartlettroscoe committed Aug 22, 2023
1 parent 954eed2 commit ca289b1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
27 changes: 22 additions & 5 deletions test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ TribitsExampleProject2_explicit_tpl_vars(SHARED)
########################################################################


function(TribitsExampleProject2_find_package sharedOrStatic package1TribitsOrRawCMake)
function(TribitsExampleProject2_find_package sharedOrStatic package1TribitsOrRawCMake
packageUseTribitsTestFunctions
)

TribitsExampleProject2_test_setup_header()

Expand All @@ -559,6 +561,19 @@ function(TribitsExampleProject2_find_package sharedOrStatic package1TribitsOrR
message(FATAL_ERROR "package1UseRawCMakeArgs='${package1UseRawCMakeArgs}' Invalid!")
endif()

if (package1TribitsOrRawCMake STREQUAL "PACKAGE1_USE_RAW_CMAKE")
if (packageUseTribitsTestFunctions STREQUAL "PACKAGE1_USE_TRIBITS_TEST_FUNCTIONS")
list(APPEND package1UseRawCMakeArgs
"-D Package1_USE_TRIBITS_TEST_FUNCTIONS=TRUE" )
string(APPEND testNameSuffix "_${packageUseTribitsTestFunctions}" )
list(APPEND package1ConfiRegex
"Using TriBITS Test Functions in a raw CMake Package1 build" )
else()
list(APPEND package1ConfiRegex
"Using Raw CMake add_test[(][)] in a raw CMake Package1 build" )
endif()
endif()

# Allow skipping delete of src and build dirs to aid in debugging
if (TribitsExampleProject2_Tests_SKIP_DELETE_SRC_AND_BUILD)
set(deleteSrcAndBuildDirsCmndArgs
Expand Down Expand Up @@ -687,10 +702,12 @@ function(TribitsExampleProject2_find_package sharedOrStatic package1TribitsOrR
endfunction()


TribitsExampleProject2_find_package(STATIC "")
TribitsExampleProject2_find_package(SHARED "")
TribitsExampleProject2_find_package(STATIC PACKAGE1_USE_RAW_CMAKE)
TribitsExampleProject2_find_package(SHARED PACKAGE1_USE_RAW_CMAKE)
TribitsExampleProject2_find_package(STATIC "" "")
TribitsExampleProject2_find_package(SHARED "" "")
TribitsExampleProject2_find_package(STATIC PACKAGE1_USE_RAW_CMAKE "")
TribitsExampleProject2_find_package(SHARED PACKAGE1_USE_RAW_CMAKE "")
TribitsExampleProject2_find_package(SHARED PACKAGE1_USE_RAW_CMAKE
PACKAGE1_USE_TRIBITS_TEST_FUNCTIONS)


########################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tribits_add_test(package1-prg NOEXEPREFIX NOEXESUFFIX
NAME Prg DIRECTORY ${PACKAGE_BINARY_DIR}/src NUM_MPI_PROCS 1
PASS_REGULAR_EXPRESSION "Package1 Deps: tpl1" )
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
include_raw_cmake_build()

tribits_add_test(package1-prg NOEXEPREFIX NOEXESUFFIX
NAME Prg DIRECTORY ${PACKAGE_BINARY_DIR}/src NUM_MPI_PROCS 1
PASS_REGULAR_EXPRESSION "Package1 Deps: tpl1" )
if ((NOT COMMAND tribits_project) OR Package1_USE_RAW_CMAKE)
if (Package1_USE_TRIBITS_TEST_FUNCTIONS)
message("-- Using TriBITS Test Functions in a raw CMake Package1 build!")
include("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.tribits.cmake")
else()
message("-- Using Raw CMake add_test() in a raw CMake Package1 build!")
include("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.raw.cmake")
endif()
else()
include("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.tribits.cmake")
endif()

0 comments on commit ca289b1

Please sign in to comment.