From 07854ff9d22bfb24cdec8c62f2d08fe18e90440f Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 18 Aug 2022 18:34:01 -0600 Subject: [PATCH 1/2] WIP: Add (failing) tests for tests/examples disable behavior (#268) This shows the behavior that is more logical for _ENABLE_[TESTS|EXAMPLES]=OFF setting default for _ENABLE_[TESTS|EXAMPLES]=OFF. --- test/core/DependencyUnitTests/CMakeLists.txt | 82 +++++++++++++++++++ .../TribitsExampleProject_Tests.cmake | 50 +++++++++++ 2 files changed, 132 insertions(+) diff --git a/test/core/DependencyUnitTests/CMakeLists.txt b/test/core/DependencyUnitTests/CMakeLists.txt index 2be0a4687..3677554f7 100644 --- a/test/core/DependencyUnitTests/CMakeLists.txt +++ b/test/core/DependencyUnitTests/CMakeLists.txt @@ -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 diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index c72f8a7a2..adfe735fa 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -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 From 305701267e61d21167943b177650d85f753c5411 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Wed, 17 Aug 2022 19:58:28 -0600 Subject: [PATCH 2/2] Implement disable of subpackages tests/examples based on parent disables (#268) This makes it so that setting _ENABLE_[TESTS|EXAMPLES]=OFF will set the default for its subpackages _ENABLE_[TESTS|EXAMPLES]=OFF. --- tribits/CHANGELOG.md | 15 ++--- .../TribitsAdjustPackageEnables.cmake | 62 ++++++++++++++++++- tribits/doc/guides/TribitsGuidesBody.rst | 26 ++++---- 3 files changed, 82 insertions(+), 21 deletions(-) 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: