Skip to content

Commit

Permalink
Merge pull request #518 from TriBITSPub/268-package-test-enable-off
Browse files Browse the repository at this point in the history
Implement disable of subpackages tests/examples based on parent disables (#268)
  • Loading branch information
bartlettroscoe authored Aug 19, 2022
2 parents 36415de + 3057012 commit 3559a18
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 21 deletions.
82 changes: 82 additions & 0 deletions test/core/DependencyUnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,88 @@ create_dependency_handling_test_case(
)


create_dependency_handling_test_case(
EnableEpetra_EnableThyraTpetra_EnableTests_DisableThyraTests
ARGS -DTrilinos_ENABLE_Epetra=ON -DTrilinos_ENABLE_ThyraTpetra=ON
-DTrilinos_ENABLE_TESTS=ON -DThyra_ENABLE_TESTS=OFF
PASS_REGULAR_EXPRESSION_ALL
"Disabling subpackage tests/examples based on parent package tests/examples disables ..."
"-- Setting Thyra_ENABLE_EXAMPLES=OFF because Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraTpetra_ENABLE_TESTS=OFF because parent package Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraTpetra_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
"Enabling all tests and/or examples that have not been explicitly disabled because Trilinos_ENABLE_.TESTS,EXAMPLES.=ON ..."
"-- Setting Epetra_ENABLE_TESTS=ON"
"-- Setting Epetra_ENABLE_EXAMPLES=ON"
"Final set of enabled packages: Teuchos RTOp Epetra Triutils Tpetra Thyra 6"
"Final set of enabled SE packages: Teuchos RTOp Epetra Triutils Tpetra ThyraCoreLibs ThyraTpetra Thyra 8"
)


create_dependency_handling_test_case(
EnableEpetra_EnableThyraTpetra_EnableTests_DisableThyraExamples
ARGS -DTrilinos_ENABLE_Epetra=ON -DTrilinos_ENABLE_ThyraTpetra=ON
-DTrilinos_ENABLE_TESTS=ON -DThyra_ENABLE_EXAMPLES=OFF
PASS_REGULAR_EXPRESSION_ALL
"Disabling subpackage tests/examples based on parent package tests/examples disables ..."
"-- Setting ThyraTpetra_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
"Enabling all tests and/or examples that have not been explicitly disabled because Trilinos_ENABLE_.TESTS,EXAMPLES.=ON ..."
"-- Setting Epetra_ENABLE_TESTS=ON"
"-- Setting Epetra_ENABLE_EXAMPLES=ON"
"-- Setting ThyraTpetra_ENABLE_TESTS=ON"
)


create_dependency_handling_test_case(
EnableEpetra_EnableThyraTpetra_EnableThyraTests_DisableThyraExamples
ARGS -DTrilinos_ENABLE_Epetra=ON -DTrilinos_ENABLE_ThyraTpetra=ON
-DThyra_ENABLE_TESTS=ON -DThyra_ENABLE_EXAMPLES=OFF
PASS_REGULAR_EXPRESSION_ALL
"Disabling subpackage tests/examples based on parent package tests/examples disables ..."
"-- Setting ThyraTpetra_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
"Enabling subpackage tests/examples based on parent package tests/examples enables ..."
"-- Setting ThyraTpetra_ENABLE_TESTS=ON because parent package Thyra_ENABLE_TESTS=ON"
)


create_dependency_handling_test_case(
EnableEpetra_EnableThyraTpetra_EnableTests_DisableThyraTests_DisableThyraExamples
ARGS -DTrilinos_ENABLE_Epetra=ON -DTrilinos_ENABLE_ThyraTpetra=ON
-DTrilinos_ENABLE_TESTS=ON -DThyra_ENABLE_TESTS=OFF -DThyra_ENABLE_EXAMPLES=OFF
PASS_REGULAR_EXPRESSION_ALL
"Disabling subpackage tests/examples based on parent package tests/examples disables ..."
"-- Setting ThyraTpetra_ENABLE_TESTS=OFF because parent package Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraTpetra_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
"Enabling all tests and/or examples that have not been explicitly disabled because Trilinos_ENABLE_.TESTS,EXAMPLES.=ON ..."
""
"-- Setting Epetra_ENABLE_TESTS=ON"
"-- Setting Epetra_ENABLE_EXAMPLES=ON"
FAIL_REGULAR_EXPRESSION
"-- Setting Thyra_ENABLE_EXAMPLES=OFF because Thyra_ENABLE_TESTS=OFF"
)


create_dependency_handling_test_case(
EnableEpetra_EnableThyra_EnableTests_DisableThyraTests_EnableThyraTpetraTests_EnableThyraTpetraExamples
ARGS -DTrilinos_ENABLE_Epetra=ON -DTrilinos_ENABLE_Thyra=ON
-DTrilinos_ENABLE_TESTS=ON -DThyra_ENABLE_TESTS=OFF -DThyraTpetra_ENABLE_TESTS=ON -DThyraTpetra_ENABLE_EXAMPLES=ON
PASS_REGULAR_EXPRESSION_ALL
"Disabling subpackage tests/examples based on parent package tests/examples disables ..."
"-- Setting Thyra_ENABLE_EXAMPLES=OFF because Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraCoreLibs_ENABLE_TESTS=OFF because parent package Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraEpetra_ENABLE_TESTS=OFF because parent package Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraEpetraExt_ENABLE_TESTS=OFF because parent package Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraCoreLibs_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
"-- Setting ThyraEpetra_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
"-- Setting ThyraEpetraExt_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
"Enabling all tests and/or examples that have not been explicitly disabled because Trilinos_ENABLE_.TESTS,EXAMPLES.=ON ..."
"-- Setting Epetra_ENABLE_TESTS=ON"
"-- Setting Epetra_ENABLE_EXAMPLES=ON"
FAIL_REGULAR_EXPRESSION
"-- Setting ThyraTpetra_ENABLE_TESTS=OFF because parent package Thyra_ENABLE_TESTS=OFF"
"-- Setting ThyraTpetra_ENABLE_EXAMPLES=OFF because parent package Thyra_ENABLE_EXAMPLES=OFF"
)


create_dependency_handling_test_case(
TestTrueFalse
ARGS -DTrilinos_ENABLE_ALL_PACKAGES=TRUE -DTrilinos_ENABLE_Zoltan=TRUE
Expand Down
50 changes: 50 additions & 0 deletions test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,56 @@ tribits_add_advanced_test( TribitsExampleProject_EnableWithSubpackagesB_EnableWi
########################################################################


tribits_add_advanced_test( TribitsExampleProject_ST_EnableSimpleCxx_EnableWithSubpackagesB_EnableTests_DisableWithsubpackagesTests
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
EXCLUDE_IF_NOT_TRUE ${PROJECT_NAME}_ENABLE_Fortran
XHOSTTYPE "Darwin"

TEST_0
MESSAGE "Configure while disabling WithSubPackages tests and examples"
CMND ${CMAKE_COMMAND}
ARGS
${TribitsExampleProject_COMMON_CONFIG_ARGS}
-DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON
-DTribitsExProj_ENABLE_SimpleCxx=ON
-DTribitsExProj_ENABLE_WithSubpackagesB=ON
-DWithSubpackages_ENABLE_TESTS=OFF
-DTribitsExProj_ENABLE_TESTS=ON
-DTribitsExProj_DUMP_PACKAGE_DEPENDENCIES=ON
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Disabling subpackage tests/examples based on parent package tests/examples disables ..."
"-- Setting WithSubpackages_ENABLE_EXAMPLES=OFF because WithSubpackages_ENABLE_TESTS=OFF"
"-- Setting WithSubpackagesB_ENABLE_TESTS=OFF because parent package WithSubpackages_ENABLE_TESTS=OFF"
"-- Setting WithSubpackagesB_ENABLE_EXAMPLES=OFF because parent package WithSubpackages_ENABLE_EXAMPLES=OFF"
"Enabling all tests and/or examples that have not been explicitly disabled because TribitsExProj_ENABLE_.TESTS,EXAMPLES.=ON ..."
"-- Setting SimpleCxx_ENABLE_TESTS=ON"
"-- Setting SimpleCxx_ENABLE_EXAMPLES=ON"
"Processing enabled package: SimpleCxx [(]Libs, Tests, Examples[)]"
"-- Performing Test HAVE_SIMPLECXX___INT64"
"-- Performing Test HAVE_SIMPLECXX___INT64 - Failed"
"Processing enabled package: MixedLang [(]Libs[)]"
"Processing enabled package: WithSubpackages [(]A, B[)]"
"Configuring done"
"Generating done"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_1 CMND make ARGS ${CTEST_BUILD_FLAGS}

TEST_2 CMND ${CMAKE_CTEST_COMMAND}
PASS_REGULAR_EXPRESSION_ALL
"SimpleCxx_HelloWorldTests.* [.]+ +Passed"
"SimpleCxx_HelloWorldProg.* [.]+ +Passed"
"100% tests passed, 0 tests failed out of 2"

)


########################################################################


tribits_add_advanced_test( TribitsExampleProject_ST_EnableMixedLang_EnableAllForwardDepPackages
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
Expand Down
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 3559a18

Please sign in to comment.