diff --git a/tribits/CHANGELOG.md b/tribits/CHANGELOG.md index de889ddac..7e3e02001 100644 --- a/tribits/CHANGELOG.md +++ b/tribits/CHANGELOG.md @@ -2,6 +2,14 @@ ChangeLog for TriBITS ---------------------------------------- +## 2022-08-18: + +* **Changed:** Made setting parent package tests/examples enable/disable + correctly propagate down to subpackages in a more intuitive way (see + [TriBITSPub/TriBITS#268](https://github.com/TriBITSPub/TriBITS/issues/268)). + This also results in not enabling tests for subpackages that are not + explicitly enabled or enabled as part of the forward sweep of packages + enables due to `_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON`. ## 2022-08-11: @@ -11,13 +19,6 @@ ChangeLog for TriBITS and [TriBITSPub/TriBITS#510](https://github.com/TriBITSPub/TriBITS/issues/510)). -* **Changed:** Made setting parent package tests/examples enables correctly - propagate down to subpackages in a more intuitive way (see - [TriBITSPub/TriBITS#268](https://github.com/TriBITSPub/TriBITS/issues/268)). - This also results in not enabling tests for subpackages that are not - explicitly enabled or enabled as part of the forward sweep of packages - enables due to `_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON`. - ## 2022-07-20: * **Changed:** Fixed TriBITS generated and installed `Config.cmake` diff --git a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake index 6c157ce97..5b26b5549 100644 --- a/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake +++ b/tribits/core/package_arch/TribitsAdjustPackageEnables.cmake @@ -999,10 +999,59 @@ macro(tribits_apply_test_example_enables PACKAGE_NAME) endmacro() -# Macro to set ${TRIBITS_SUBPACKAGE)_ENABLE_TESTS and +# Macro to disable ${PARENT_PACKAGE_NAME)_ENABLE_ENABLES by default if +# ${PARENT_PACKAGE_NAME)_ENABLE_TESTS is explicitly disabled. +# +macro(tribits_apply_package_examples_disable PARENT_PACKAGE_NAME) + if (NOT "${${PARENT_PACKAGE_NAME}_ENABLE_TESTS}" STREQUAL "" + AND NOT ${PARENT_PACKAGE_NAME}_ENABLE_TESTS + AND "${${PARENT_PACKAGE_NAME}_ENABLE_EXAMPLES}" STREQUAL "" + ) + message("-- " "Setting" + " ${PARENT_PACKAGE_NAME}_ENABLE_EXAMPLES" + "=${${PARENT_PACKAGE_NAME}_ENABLE_TESTS}" + " because" + " ${PARENT_PACKAGE_NAME}_ENABLE_TESTS" + "=${${PARENT_PACKAGE_NAME}_ENABLE_TESTS}" ) + set(${PARENT_PACKAGE_NAME}_ENABLE_EXAMPLES ${${PARENT_PACKAGE_NAME}_ENABLE_TESTS}) + endif() +endmacro() +# NOTE: Above, the top-level package ${PARENT_PACKAGE_NAME} may not even be +# enabled yet when this gets called but its subpackages might and we need to +# process this default disable in case their are any enabled subpackages. + + +# Macro to disable ${TRIBITS_SUBPACKAGE)_ENABLE_TESTS and +# ${TRIBITS_SUBPACKAGE)_ENABLE_EXAMPLES based on +# ${TRIBITS_PARENTPACKAGE)_ENABLE_TESTS or +# ${TRIBITS_PARENTPACKAGE)_ENABLE_EXAMPLES +# +macro(tribits_apply_subpackage_tests_or_examples_disables PARENT_PACKAGE_NAME + TESTS_OR_EXAMPLES + ) + set(parentPkgEnableVar ${PARENT_PACKAGE_NAME}_ENABLE_${TESTS_OR_EXAMPLES}) + if (NOT "${${parentPkgEnableVar}}" STREQUAL "" AND NOT ${parentPkgEnableVar}) + foreach(spkg IN LISTS ${PARENT_PACKAGE_NAME}_SUBPACKAGES) + set(fullSpkgName ${PARENT_PACKAGE_NAME}${spkg}) + if (${PROJECT_NAME}_ENABLE_${fullSpkgName} AND NOT ${parentPkgEnableVar}) + if ("${${fullSpkgName}_ENABLE_${TESTS_OR_EXAMPLES}}" STREQUAL "") + message("-- " "Setting" + " ${fullSpkgName}_ENABLE_${TESTS_OR_EXAMPLES}=${${parentPkgEnableVar}}" + " because parent package" + " ${parentPkgEnableVar}=${${parentPkgEnableVar}}") + set(${fullSpkgName}_ENABLE_${TESTS_OR_EXAMPLES} ${${parentPkgEnableVar}}) + endif() + endif() + endforeach() + endif() +endmacro() + + +# Macro to enable ${TRIBITS_SUBPACKAGE)_ENABLE_TESTS and # ${TRIBITS_SUBPACKAGE)_ENABLE_EXAMPLES based on # ${TRIBITS_PARENTPACKAGE)_ENABLE_TESTS or # ${TRIBITS_PARENTPACKAGE)_ENABLE_EXAMPLES +# macro(tribits_apply_subpackage_tests_examples_enables PARENT_PACKAGE_NAME) if ("${${PARENT_PACKAGE_NAME}_ENABLE_EXAMPLES}" STREQUAL "" AND ${PARENT_PACKAGE_NAME}_ENABLE_TESTS @@ -1399,9 +1448,18 @@ macro(tribits_adjust_package_enables) ${PROJECT_NAME}_ENABLED_SE_PACKAGES "") # - # C) Enable tests for currently enabled SE packages + # C) Disable and enable tests for currently enabled SE packages # + message("") + message("Disabling subpackage tests/examples based on parent package tests/examples disables ...") + message("") + foreach(TRIBITS_PACKAGE ${${PROJECT_NAME}_PACKAGES}) + tribits_apply_package_examples_disable(${TRIBITS_PACKAGE} TESTS) + tribits_apply_subpackage_tests_or_examples_disables(${TRIBITS_PACKAGE} TESTS) + tribits_apply_subpackage_tests_or_examples_disables(${TRIBITS_PACKAGE} EXAMPLES) + endforeach() + if (${PROJECT_NAME}_ENABLE_TESTS OR ${PROJECT_NAME}_ENABLE_EXAMPLES) message("") message("Enabling all tests and/or examples that have not been" diff --git a/tribits/doc/guides/TribitsGuidesBody.rst b/tribits/doc/guides/TribitsGuidesBody.rst index 848f5aea1..293fcca3e 100644 --- a/tribits/doc/guides/TribitsGuidesBody.rst +++ b/tribits/doc/guides/TribitsGuidesBody.rst @@ -3378,7 +3378,7 @@ management system are: 9) `TPL disable triggers auto-disables of downstream dependencies`_ 10) `Disables trump enables where there is a conflict`_ 11) `Enable/disable of parent package is enable/disable for subpackages`_ -12) `Enable of parent package tests/examples is enable for subpackages tests/examples`_ +12) `Enable/disable of parent package tests/examples is enable/disable for subpackages tests/examples`_ 13) `Subpackage enable does not auto-enable the parent package`_ 14) `Support for optional SE package/TPL is enabled by default`_ 15) `Support for optional SE package/TPL can be explicitly disabled`_ @@ -3588,17 +3588,19 @@ In more detail, these rules/behaviors are: see `Explicit enable of a package, its tests, an optional TPL, with ST enabled`_. -.. _Enable of parent package tests/examples is enable for subpackages tests/examples: - -12) **Enable of parent package tests/examples is enable for subpackages - tests/examples**: Setting ``_ENABLE_TESTS=ON`` is - equivalent to setting the default for - ``_ENABLE_TESTS=ON`` for each subpackage ```` of - the parent package ```` (if ```` has - subpackages). Same is true for ``_ENABLE_EXAMPLES=ON`` - setting the default for ``_ENABLE_EXAMPLES=ON``. In - addition, setting ``_ENABLE_TESTS=ON`` will set - ``_ENABLE_EXAMPLES=ON`` by default as well. +.. _Enable/disable of parent package tests/examples is enable/disable for subpackages tests/examples: + +12) **Enable/disable of parent package tests/examples is enable/disable for + subpackages tests/examples**: Setting + ``_ENABLE_TESTS=[ON|OFF]`` is equivalent to setting the + default for ``_ENABLE_TESTS=[ON|OFF]`` for each + subpackage ```` of the parent package ```` (if + ```` has subpackages). Same is true for + ``_ENABLE_EXAMPLES=[ON|OFF]`` setting the default for + ``_ENABLE_EXAMPLES=[ON|OFF]``. In addition, setting + ``_ENABLE_TESTS=[ON|OFF]`` will set + ``_ENABLE_EXAMPLES=[ON|OFF]`` by default as well (but not + vice versa). .. _Subpackage enable does not auto-enable the parent package: