Skip to content

Commit

Permalink
Fix tribits_ctest_driver() package-by-package robust mode for CMake 3…
Browse files Browse the repository at this point in the history
….19+ (TriBITSPub#363, TriBITSPub#394)

I also added another test case for when libs are broken in required upstream
package.

See the detailed comments, especially in the file
TribitsCTestDriverCoreHelpers.cmake.
  • Loading branch information
bartlettroscoe committed Aug 12, 2021
1 parent ab919c0 commit fc5992d
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 7 deletions.
8 changes: 3 additions & 5 deletions test/ctest_driver/MockCTestDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ create_ctest_dependency_handling_test_case(
"Final set of enabled packages: Teuchos 1"
"Final set of non-enabled packages: TrilinosFramework RTOp Epetra Zoltan Shards Triutils Tpetra EpetraExt Stokhos Sacado Thyra Isorropia AztecOO Galeri Amesos Intrepid Ifpack ML Belos Stratimikos RBGen Phalanx Panzer 23"
"Processing current package Teuchos: libs='ON', tests='ON'"
"CONFIGURE_OPTIONS = '-DTrilinos_TRIBITS_DIR=.+.-DCTEST_USE_LAUNCHERS:BOOL=1.-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON.-DTrilinos_WARNINGS_AS_ERRORS_FLAGS:STRING=-DummyErrFlags.-DTrilinos_ALLOW_NO_PACKAGES:BOOL=ON.-DTrilinos_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON.-DTrilinos_ENABLE_SECONDARY_TESTED_CODE:BOOL=OFF.-DTrilinos_EXTRAREPOS_FILE:STRING=.*./MockTrilinos/cmake.ExtraRepositoriesList.cmake.-DTrilinos_IGNORE_MISSING_EXTRA_REPOSITORIES:BOOL=ON.-DTrilinos_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE:STRING=Experimental.-DTrilinos_ENABLE_TESTS:BOOL=ON.-DTrilinos_ENABLE_Teuchos:BOOL=ON'"
"CONFIGURE_OPTIONS = '-DTrilinos_TRIBITS_DIR=.+[;]-DCTEST_USE_LAUNCHERS:BOOL=1[;]-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON[;]-DTrilinos_WARNINGS_AS_ERRORS_FLAGS:STRING=-DummyErrFlags[;]-DTrilinos_ALLOW_NO_PACKAGES:BOOL=ON[;]-DTrilinos_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON[;]-DTrilinos_ENABLE_SECONDARY_TESTED_CODE:BOOL=OFF[;]-DTrilinos_EXTRAREPOS_FILE:STRING=.*./MockTrilinos/cmake.ExtraRepositoriesList.cmake[;]-DTrilinos_IGNORE_MISSING_EXTRA_REPOSITORIES:BOOL=ON[;]-DTrilinos_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE:STRING=Experimental[;]-DTrilinos_ENABLE_TESTS:BOOL=ON[;]-DTrilinos_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON[;]-DTrilinos_ENABLE_Teuchos:BOOL=ON'"
)
# NOTE: The above test pins down the form of the configure options passed to
# different package configures to make sure everything in there.
Expand Down Expand Up @@ -245,10 +245,10 @@ create_ctest_dependency_handling_test_case(
"Final set of enabled packages: Teuchos RTOp Epetra Zoltan Triutils Tpetra EpetraExt Thyra 8"
"Final set of non-enabled packages: TrilinosFramework Shards Stokhos Sacado Isorropia AztecOO Galeri Amesos Intrepid Ifpack ML Belos Stratimikos RBGen Phalanx Panzer 16"
"Processing current package Teuchos: libs='ON', tests=''"
"CONFIGURE_OPTIONS = '-DTrilinos_TRIBITS_DIR=.+-DCTEST_USE_LAUNCHERS:BOOL=1.-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON.-DTrilinos_WARNINGS_AS_ERRORS_FLAGS:STRING=-DummyErrFlags.-DTrilinos_ALLOW_NO_PACKAGES:BOOL=ON.-DTrilinos_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON.-DTrilinos_ENABLE_SECONDARY_TESTED_CODE:BOOL=OFF.-DTrilinos_EXTRAREPOS_FILE:STRING=.+/examples/MockTrilinos/cmake/ExtraRepositoriesList.cmake.-DTrilinos_IGNORE_MISSING_EXTRA_REPOSITORIES:BOOL=ON.-DTrilinos_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE:STRING=Experimental.-DTrilinos_ENABLE_TESTS:BOOL=.-DTrilinos_ENABLE_Teuchos:BOOL=ON'"
"CONFIGURE_OPTIONS = '-DTrilinos_TRIBITS_DIR=.+-DCTEST_USE_LAUNCHERS:BOOL=1[;]-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON[;]-DTrilinos_WARNINGS_AS_ERRORS_FLAGS:STRING=-DummyErrFlags[;]-DTrilinos_ALLOW_NO_PACKAGES:BOOL=ON[;]-DTrilinos_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON[;]-DTrilinos_ENABLE_SECONDARY_TESTED_CODE:BOOL=OFF[;]-DTrilinos_EXTRAREPOS_FILE:STRING=.+/examples/MockTrilinos/cmake/ExtraRepositoriesList.cmake[;]-DTrilinos_IGNORE_MISSING_EXTRA_REPOSITORIES:BOOL=ON[;]-DTrilinos_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE:STRING=Experimental[;]-DTrilinos_ENABLE_TESTS:BOOL=[;]-DTrilinos_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON[;]-DTrilinos_ENABLE_Teuchos:BOOL=ON'"
"Processing current package Epetra: libs='ON', tests=''"
"Processing current package Thyra: libs='ON', tests='ON'"
"CONFIGURE_OPTIONS = '-DTrilinos_TRIBITS_DIR=.+-DCTEST_USE_LAUNCHERS:BOOL=1.-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON.-DTrilinos_WARNINGS_AS_ERRORS_FLAGS:STRING=-DummyErrFlags.-DTrilinos_ALLOW_NO_PACKAGES:BOOL=ON.-DTrilinos_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON.-DTrilinos_ENABLE_SECONDARY_TESTED_CODE:BOOL=OFF.-DTrilinos_EXTRAREPOS_FILE:STRING=.+/examples/MockTrilinos/cmake/ExtraRepositoriesList.cmake.-DTrilinos_IGNORE_MISSING_EXTRA_REPOSITORIES:BOOL=ON.-DTrilinos_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE:STRING=Experimental.-DTrilinos_ENABLE_TESTS:BOOL=ON.-DTrilinos_ENABLE_EpetraExt:BOOL=.-DTrilinos_ENABLE_Thyra:BOOL=ON'"
"CONFIGURE_OPTIONS = '-DTrilinos_TRIBITS_DIR=.+-DCTEST_USE_LAUNCHERS:BOOL=1[;]-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON[;]-DTrilinos_WARNINGS_AS_ERRORS_FLAGS:STRING=-DummyErrFlags[;]-DTrilinos_ALLOW_NO_PACKAGES:BOOL=ON[;]-DTrilinos_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON[;]-DTrilinos_ENABLE_SECONDARY_TESTED_CODE:BOOL=OFF[;]-DTrilinos_EXTRAREPOS_FILE:STRING=.+/examples/MockTrilinos/cmake/ExtraRepositoriesList.cmake[;]-DTrilinos_IGNORE_MISSING_EXTRA_REPOSITORIES:BOOL=ON[;]-DTrilinos_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE:STRING=Experimental[;]-DTrilinos_ENABLE_TESTS:BOOL=ON[;]-DTrilinos_ENABLE_EpetraExt:BOOL=[;]-DTrilinos_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON[;]-DTrilinos_ENABLE_Thyra:BOOL=ON'"
)
# NOTE: The above test pins down the form of the configure options passed to
# different package configures to make sure everything in there.
Expand Down Expand Up @@ -1162,5 +1162,3 @@ tribits_add_advanced_test( CTestDriver_tribits_ctest_update_commands_wrapper_def
"Git Update PASSED!"

)


61 changes: 59 additions & 2 deletions test/ctest_driver/TribitsExampleProject/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ tribits_add_advanced_test( CTestDriver_PBP_ST_BreakConfigureRequiredPkg
CMND cp
ARGS -r ${TribitsExProj_DIR} .
TEST_1
MESSAGE "Break the confgiure for just the required SimpleCxx package"
MESSAGE "Break the configure for just the required SimpleCxx package"
CMND ${CMAKE_CURRENT_SOURCE_DIR}/append_file_with_line.sh
ARGS TribitsExampleProject/packages/simple_cxx/CMakeLists.txt
"Configure of SimpleCxx is broken!"
Expand Down Expand Up @@ -542,7 +542,64 @@ tribits_add_advanced_test( CTestDriver_PBP_ST_BreakConfigureRequiredPkg
# NOTE: The above test ensures that the configure failure of an upstream
# optional package does not break the configure, build, or tests of
# downstream packages. It only disables the broken upstream package in
# downstream packages.
# downstream packages. This provides a robust package-by-package mode where
# configure errors in required upstream packages result in the graceful
# disable of downstream packages so that they don't report errors for those
# packages when the problem is really in upstream packages. See the var
# ${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES that is passed
# through in package-by-package mode and GitHub PR TriBITSPub/TriBITS#394.


tribits_add_advanced_test( CTestDriver_PBP_ST_BreakBuildLibRequiredPkg
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
EXCLUDE_IF_NOT_TRUE ${PROJECT_NAME}_ENABLE_Fortran
TEST_0
MESSAGE "Copy the project dir so I can break it!"
CMND cp
ARGS -r ${TribitsExProj_DIR} .
TEST_1
MESSAGE "Break the build of a lib for the required SimpleCxx package"
CMND ${CMAKE_CURRENT_SOURCE_DIR}/append_file_with_line.sh
ARGS TribitsExampleProject/packages/simple_cxx/src/SimpleCxx_HelloWorld.cpp
"Build of the SimpleCxx library is broken!"
TEST_2
MESSAGE "Run ctest driver which should show a failed lib build for just the SimpleCxx package!"
CMND env
ARGS
CTEST_DASHBOARD_ROOT=PWD
${PBP_COMMON_ENV_ARGS}
TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=TRUE
${CTEST_DROP_SITE_ENV_ARGS}
CTEST_BUILD_NAME=${PACKAGE_NAME}_CTestDriver_PBP_ST_BreakBuildLibRequiredPkg
${CTEST_S_SCRIPT_ARGS}
PASS_REGULAR_EXPRESSION_ALL
"Final set of enabled SE packages: SimpleCxx MixedLang WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages WrapExternal 7"
"SimpleCxx: Configure passed"
"FAILED library build for package 'SimpleCxx'"
"SimpleCxx: Skipping tests since libray build failed"
"CONFIGURE_OPTIONS = '.*[;]-DTribitsExProj_ENABLE_SimpleCxx:BOOL=OFF[;].*[;]-DTribitsExProj_ENABLE_MixedLang:BOOL=ON'"
"MixedLang: Configure passed"
"MixedLang: Libs build passed"
"MixedLang_RayTracerTests [.]+ +Passed"
"CONFIGURE_OPTIONS = '.*[;]-DTribitsExProj_ENABLE_SimpleCxx:BOOL=OFF[;].*[;]-DTribitsExProj_ENABLE_WithSubpackages:BOOL=ON'"
"WithSubpackages: Configure passed"
"WithSubpackages: Libs build passed"
"WithSubpackages: All build passed"
"No tests were found" # Can't tell which package :-(
"CONFIGURE_OPTIONS = '.*[;]-DTribitsExProj_ENABLE_SimpleCxx:BOOL=OFF[;].*[;]-DTribitsExProj_ENABLE_WrapExternal:BOOL=ON'"
"WrapExternal: Configure passed"
"WrapExternal: All build passed"
"Final set packages that failed to configure or have the libraries build: 'SimpleCxx'"
"Final set of packages that had any failures: 'SimpleCxx'"
"TRIBITS_CTEST_DRIVER: OVERALL: ALL FAILED"
ALWAYS_FAIL_ON_ZERO_RETURN
)
# NOTE: The above test is similar to the test
# CTestDriver_PBP_ST_BreakConfigureRequiredPkg except the above test is for
# the case where a library in a required upstream package does not build and
# we want those downstream packages with a required dependency on that
# package to be gracefully disabled.


tribits_add_advanced_test( CTestDriver_PBP_ST_ALL_COVERAGE
Expand Down
24 changes: 24 additions & 0 deletions tribits/core/package_arch/TribitsGlobalMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,21 @@ macro(tribits_configure_enabled_packages)
add_dependencies(libs ${ENABLED_PACKAGE_LIBS_TARGETS})
endif()

# Add empty <PackageName>_libs targets for top-level packages if asked
if (${PROJECT_NAME}_DEFINE_MISSING_PACKAGE_LIBS_TARGETS)
foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES})
if (NOT TARGET ${TRIBITS_PACKAGE}_libs)
add_custom_target(${TRIBITS_PACKAGE}_libs
COMMENT "Dummy target for ${TRIBITS_PACKAGE}_libs that builds nothing!")
endif()
endforeach()
endif()
# NOTE: For motivation for above, see the comment about the setting of
# ${PROJECT_NAME}_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON in
# package-by-package mode in tribits_ctest_driver(). This option is
# purposefully not documented and not defined as a cache variable since it
# is an internal TriBITS implementation detail.

endif()

tribits_config_code_stop_timer(CONFIGURE_PACKAGES_TIME_START_SECONDS
Expand Down Expand Up @@ -2702,3 +2717,12 @@ macro(tribits_exclude_autotools_files) # PACKAGE_NAME LIST_RETURN)
tribits_exclude_files(${FILES_TO_EXCLUDE})

endmacro()

# LocalWords:
# LocalWords: Sandia SANDIA Redistributions
# LocalWords: tribits TriBITS TRIBITS
# LocalWords: cmake CMake CMAKE CMakeCache CMakeFiles
# LocalWords: ctest CPACK
# LocalWords: foreach endforeach endif endmacro
# LocalWords: BOOL
# LocalWords: libs LIBS config PackageName SUBPACKAGES nonenabled
19 changes: 19 additions & 0 deletions tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,8 @@ macro(tribits_ctest_package_by_package)
"-D${PROJECT_NAME}_ENABLE_${${PROJECT_NAME}_LAST_CONFIGURED_PACKAGE}:BOOL=")
set(${PROJECT_NAME}_LAST_CONFIGURED_PACKAGE)
endif()
list(APPEND CONFIGURE_OPTIONS
"-D${PROJECT_NAME}_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON")
foreach(FAILED_PACKAGE ${${PROJECT_NAME}_FAILED_LIB_BUILD_PACKAGES})
list(APPEND CONFIGURE_OPTIONS
"-D${PROJECT_NAME}_ENABLE_${FAILED_PACKAGE}:BOOL=OFF")
Expand Down Expand Up @@ -1315,6 +1317,23 @@ macro(tribits_ctest_package_by_package)
" ${PROJECT_NAME} packages!\n")

endmacro()
# NOTE: Above, the option
# ${PROJECT_NAME}_DEFINE_MISSING_PACKAGE_LIBS_TARGETS=ON is passed down
# through to the inner CMake TriBITS configure to trigger the creation of
# dummy targets <PackageName>_libs for all the packages for the case where a
# package is disabled due to a disabled upstream package and
# ${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON but the target
# <thePackage>_libs is attempted to be built anyway and we expect it to build
# nothing and result in no error. (The outer ctest -S driver is not smart
# enough to know all the lgoic for if a package will actaully be enabled or
# not. That is the job of the inner TriBITS dependency logic and
# ${PROJECT_NAME}_DISABLE_ENABLED_FORWARD_DEP_PACKAGES=ON.) Otherwise, with
# CMake 3.19+, cmake_build() catches errors in undefined global build targets
# like this and reports them correctly. This workaround allows the
# package-by-package mode to gracefully disable downstream packages that can't
# be enabled due to the disable of a broken upstream packages. See the test
# TriBITS_CTestDriver_PBP_ST_BreakConfigureRequiredPkg that exercises this use
# case.


# Drive the configure, build, test, and submit all at once for all of the
Expand Down

0 comments on commit fc5992d

Please sign in to comment.