Skip to content

Commit

Permalink
Implement disable of subpackages tests/examples based on parent disab…
Browse files Browse the repository at this point in the history
…les (#268)

This makes it so that setting <ParentPackage>_ENABLE_[TESTS|EXAMPLES]=OFF will
set the default for its subpackages
<ParentPackage><Spkg>_ENABLE_[TESTS|EXAMPLES]=OFF.
  • Loading branch information
bartlettroscoe committed Aug 19, 2022
1 parent 07854ff commit 3057012
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 21 deletions.
15 changes: 8 additions & 7 deletions tribits/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<Project>_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON`.

## 2022-08-11:

Expand All @@ -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 `<Project>_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON`.

## 2022-07-20:

* **Changed:** Fixed TriBITS generated and installed `<tplName>Config.cmake`
Expand Down
62 changes: 60 additions & 2 deletions tribits/core/package_arch/TribitsAdjustPackageEnables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
26 changes: 14 additions & 12 deletions tribits/doc/guides/TribitsGuidesBody.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`_
Expand Down Expand Up @@ -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 ``<TRIBITS_PACKAGE>_ENABLE_TESTS=ON`` is
equivalent to setting the default for
``<TRIBITS_PACKAGE><SP>_ENABLE_TESTS=ON`` for each subpackage ``<SP>`` of
the parent package ``<TRIBITS_PACKAGE>`` (if ``<TRIBITS_PACKAGE>`` has
subpackages). Same is true for ``<TRIBITS_PACKAGE>_ENABLE_EXAMPLES=ON``
setting the default for ``<TRIBITS_PACKAGE><SP>_ENABLE_EXAMPLES=ON``. In
addition, setting ``<TRIBITS_PACKAGE>_ENABLE_TESTS=ON`` will set
``<TRIBITS_PACKAGE>_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
``<TRIBITS_PACKAGE>_ENABLE_TESTS=[ON|OFF]`` is equivalent to setting the
default for ``<TRIBITS_PACKAGE><SP>_ENABLE_TESTS=[ON|OFF]`` for each
subpackage ``<SP>`` of the parent package ``<TRIBITS_PACKAGE>`` (if
``<TRIBITS_PACKAGE>`` has subpackages). Same is true for
``<TRIBITS_PACKAGE>_ENABLE_EXAMPLES=[ON|OFF]`` setting the default for
``<TRIBITS_PACKAGE><SP>_ENABLE_EXAMPLES=[ON|OFF]``. In addition, setting
``<TRIBITS_PACKAGE>_ENABLE_TESTS=[ON|OFF]`` will set
``<TRIBITS_PACKAGE>_ENABLE_EXAMPLES=[ON|OFF]`` by default as well (but not
vice versa).

.. _Subpackage enable does not auto-enable the parent package:

Expand Down

0 comments on commit 3057012

Please sign in to comment.