TestImpactTestTargetConfig.cmake 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. if(NOT PAL_TRAIT_BUILD_TESTS_SUPPORTED)
  9. return()
  10. endif()
  11. # Path to test instrumentation binary
  12. set(O3DE_TEST_IMPACT_INSTRUMENTATION_BIN "" CACHE PATH "Path to test impact framework instrumentation binary")
  13. # Label to add to test for them to be included in TIAF
  14. set(REQUIRES_TIAF_LABEL "REQUIRES_tiaf")
  15. # Test impact analysis opt-in for native test targets
  16. set(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED FALSE CACHE BOOL "Whether to enable native C++ test targets with the REQUIRES_TIAF_LABEL label for test impact analysis (otherwise, CTest will be used to run these targets).")
  17. # Test impact analysis opt-in for Python test targets
  18. set(O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED FALSE CACHE BOOL "Whether to enable Python test targets with the REQUIRES_TIAF_LABEL label for test impact analysis (otherwise, CTest will be used to run these targets).")
  19. if(LY_MONOLITHIC_GAME)
  20. # TIAF not supported for monolithic game builds
  21. set(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED false)
  22. set(O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED false)
  23. set(O3DE_TEST_IMPACT_ACTIVE false)
  24. elseif(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED OR O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED)
  25. # TIAF is active if at least one runtime is enabled
  26. set(O3DE_TEST_IMPACT_ACTIVE true)
  27. if(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED)
  28. message(DEBUG "TIAF enabled for native tests.")
  29. else()
  30. message("TIAF disabled for native tests.")
  31. endif()
  32. if(O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED)
  33. message(DEBUG "TIAF enabled for Python tests.")
  34. else()
  35. message(DEBUG "TIAF disabled for Python tests.")
  36. endif()
  37. else()
  38. set(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED false)
  39. set(O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED false)
  40. set(O3DE_TEST_IMPACT_ACTIVE false)
  41. message(DEBUG "TIAF disabled. No test target types will be opted in.")
  42. endif()
  43. #! o3de_test_impact_apply_test_labels: applies the the appropriate label to a test target for running in CTest according to whether
  44. # or not their test framework type is enabled for running in TIAF.
  45. #
  46. # \arg:TEST_FRAMEWORK The test framework type of the test target
  47. # \arg:TEST_LABELS The existing test labels list that the TIAF label will be appended to
  48. function(o3de_test_impact_apply_test_labels TEST_FRAMEWORK TEST_LABELS)
  49. if("${TEST_FRAMEWORK}" STREQUAL "pytest" OR "${TEST_FRAMEWORK}" STREQUAL "pytest_editor")
  50. if(NOT O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED)
  51. set(remove_tiaf_label ON)
  52. endif()
  53. elseif("${TEST_FRAMEWORK}" STREQUAL "googletest" OR "${TEST_FRAMEWORK}" STREQUAL "googlebenchmark")
  54. if(NOT O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED)
  55. set(remove_tiaf_label ON)
  56. endif()
  57. endif()
  58. if(remove_tiaf_label)
  59. list(REMOVE_ITEM ${TEST_LABELS} ${REQUIRES_TIAF_LABEL})
  60. set(${TEST_LABELS} ${${TEST_LABELS}} PARENT_SCOPE)
  61. endif()
  62. endfunction()