TestImpactTestTargetConfig.cmake 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. # Path to test instrumentation binary
  9. set(O3DE_TEST_IMPACT_INSTRUMENTATION_BIN "" CACHE PATH "Path to test impact framework instrumentation binary")
  10. # Label to add to test for them to be included in TIAF
  11. set(REQUIRES_TIAF_LABEL "REQUIRES_tiaf")
  12. # Test impact analysis opt-in for native test targets
  13. 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).")
  14. # Test impact analysis opt-in for Python test targets
  15. 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).")
  16. if(LY_MONOLITHIC_GAME)
  17. # TIAF not supported for monolithic game builds
  18. set(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED false)
  19. set(O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED false)
  20. set(O3DE_TEST_IMPACT_ACTIVE false)
  21. elseif(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED OR O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED)
  22. # TIAF is active if at least one runtime is enabled
  23. set(O3DE_TEST_IMPACT_ACTIVE true)
  24. if(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED)
  25. message(DEBUG "TIAF enabled for native tests.")
  26. else()
  27. message("TIAF disabled for native tests.")
  28. endif()
  29. if(O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED)
  30. message(DEBUG "TIAF enabled for Python tests.")
  31. else()
  32. message(DEBUG "TIAF disabled for Python tests.")
  33. endif()
  34. else()
  35. set(O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED false)
  36. set(O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED false)
  37. set(O3DE_TEST_IMPACT_ACTIVE false)
  38. message(DEBUG "TIAF disabled. No test target types will be opted in.")
  39. endif()
  40. #! o3de_test_impact_apply_test_labels: applies the the appropriate label to a test target for running in CTest according to whether
  41. # or not their test framework type is enabled for running in TIAF.
  42. #
  43. # \arg:TEST_FRAMEWORK The test framework type of the test target
  44. # \arg:TEST_LABELS The existing test labels list that the TIAF label will be appended to
  45. function(o3de_test_impact_apply_test_labels TEST_FRAMEWORK TEST_LABELS)
  46. if("${TEST_FRAMEWORK}" STREQUAL "pytest" OR "${TEST_FRAMEWORK}" STREQUAL "pytest_editor")
  47. if(NOT O3DE_TEST_IMPACT_PYTHON_TEST_TARGETS_ENABLED)
  48. set(remove_tiaf_label ON)
  49. endif()
  50. elseif("${TEST_FRAMEWORK}" STREQUAL "googletest" OR "${TEST_FRAMEWORK}" STREQUAL "googlebenchmark")
  51. if(NOT O3DE_TEST_IMPACT_NATIVE_TEST_TARGETS_ENABLED)
  52. set(remove_tiaf_label ON)
  53. endif()
  54. endif()
  55. if(remove_tiaf_label)
  56. list(REMOVE_ITEM ${TEST_LABELS} ${REQUIRES_TIAF_LABEL})
  57. set(${TEST_LABELS} ${${TEST_LABELS}} PARENT_SCOPE)
  58. endif()
  59. endfunction()