Skip to content

Commit

Permalink
WIP: Add basic tests for exporting package cache vars (TriBITSPub#516)
Browse files Browse the repository at this point in the history
This updates some existing tests for the export of selected package cache
vars, including vars from parent package in subpackage <Package>Config.cmake
files.
  • Loading branch information
bartlettroscoe committed Aug 23, 2022
1 parent 5e26300 commit 042006e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ function(TribitsExampleApp_NoFortran fullOrComponents sharedOrStatic)
${tribitsExProjUseComponentsArg}
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleApp
PASS_REGULAR_EXPRESSION_ALL
"WithSubpackagesA_SPECIAL_VALUE = '3'"
"-- Configuring done"
"-- Generating done"
"-- Build files have been written to: .*/${testName}/app_build"
Expand Down
26 changes: 19 additions & 7 deletions test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
-DTribitsExProj_DUMP_CPACK_SOURCE_IGNORE_FILES=ON
-DTribitsExProj_DUMP_PACKAGE_DEPENDENCIES=ON
-DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=ON
-DWithSubpackagesA_SPECIAL_VALUE=5
-DCMAKE_CXX_FLAGS=-DSIMPLECXX_SHOW_DEPRECATED_WARNINGS=1
-DCMAKE_INSTALL_PREFIX=install
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject
Expand Down Expand Up @@ -310,6 +311,17 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_5
MESSAGE "Grep the contents of the WithSubpackagesAConfig.cmake file in build dir"
CMND cat ARGS cmake_packages/WithSubpackagesA/WithSubpackagesAConfig.cmake
PASS_REGULAR_EXPRESSION_ALL
"# Enables/Disables for upstream package dependencies"
"set[(]WithSubpackagesA_ENABLE_SimpleCxx ON[)]"
"# Exported cache variables"
"set[(]WithSubpackages_ENABLE_DEBUG .OFF.[)]"
"set[(]HAVE_WITHSUBPACKAGES_DEBUG .OFF.[)]"
"set[(]WithSubpackagesA_SPECIAL_VALUE .5.[)]"

TEST_6
MESSAGE "Build 'install' target using raw 'make'"
CMND make ARGS install ${CTEST_BUILD_FLAGS}
PASS_REGULAR_EXPRESSION_ALL
Expand Down Expand Up @@ -343,7 +355,7 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
"Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets-release.cmake"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_6
TEST_7
MESSAGE "Create and configure a dummy project that calls"
" find_package(WithSubpackages) from the install tree"
CMND ${CMAKE_COMMAND}
Expand Down Expand Up @@ -390,7 +402,7 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
"WithSubpackages::all_libs INTERFACE_LINK_LIBRARIES: 'WithSubpackagesA::pws_a[;]WithSubpackagesB::pws_b[;]WithSubpackagesC::pws_c'"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_7
TEST_8
MESSAGE "Create and configure a dummy project that calls"
" find_package(TribitsExProj) with no components"
CMND ${CMAKE_COMMAND}
Expand Down Expand Up @@ -448,7 +460,7 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
"-- Generating done"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_8
TEST_9
MESSAGE "Create and configure a dummy project that calls find_package(TribitsExProj)"
" with required and optional components"
CMND ${CMAKE_COMMAND}
Expand Down Expand Up @@ -478,7 +490,7 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
"-- Generating done"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_9
TEST_10
MESSAGE "Run find_package() from two different subdirs with related packages"
WORKING_DIRECTORY find_package_two_dirs
CMND ${CMAKE_COMMAND}
Expand All @@ -492,7 +504,7 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
"-- Generating done"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_10
TEST_11
MESSAGE "Create the tarball"
CMND make ARGS package_source
PASS_REGULAR_EXPRESSION_ALL
Expand All @@ -509,12 +521,12 @@ function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi)
"CPack: - package: .*/ExamplesUnitTests/${testName}/tribitsexproj-1.1-Source.tar.bz2 generated."
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_11
TEST_12
MESSAGE "Untar the tarball"
CMND tar ARGS -xzf tribitsexproj-1.1-Source.tar.gz
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_12
TEST_13
MESSAGE "Make sure right directories are excluded"
CMND diff
ARGS -qr
Expand Down
3 changes: 3 additions & 0 deletions tribits/examples/TribitsExampleApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ include(AppHelperFuncs)

getTribitsExProjStuffForApp()

# Show that we can see exported cache vars
message("-- WithSubpackagesA_SPECIAL_VALUE = '${WithSubpackagesA_SPECIAL_VALUE}'")

# Enable the compilers now that we have gotten them from the *Config.cmake file
enable_language(C)
enable_language(CXX)
Expand Down

0 comments on commit 042006e

Please sign in to comment.