| # Copyright 2023 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| import("//build/board.gni") | |
| # Creates a set of standardized test groups: | |
| # | |
| # ':hermetic_tests' - A group which only contains hermetic tests, and only | |
| # exists in the default toolchain. | |
| # ':host_tests' - A group which only contains host tests, and only exists in | |
| # the host toolchain. | |
| # ':e2e_tests' - A group which only contains end-to-end tests, and only exists | |
| # in the host toolchain | |
| # ':non_hermetic_tests' - A group which only contains non-hermetic integration | |
| # tests, and only exists in the default toolchain | |
| # | |
| # The following parameters are used to provide the deps for the above groups. | |
| # These should: | |
| # 1) Only be direct labels of tests (not test groups) | |
| # 2) Not be qualified by toolchain (this is done implicitly within the | |
| # template) | |
| # 3) Not contain any targets _other_ than tests. | |
| # | |
| # - hermetic | |
| # - host | |
| # - e2e | |
| # - non_hermetic | |
| # | |
| # The target_name passed to this template is not used. | |
| # | |
| template("standardized_test_groups") { | |
| not_needed([ "target_name" ]) | |
| if (current_toolchain == default_toolchain) { | |
| group("hermetic_tests") { | |
| testonly = true | |
| deps = [] | |
| if (defined(invoker.hermetic)) { | |
| deps += invoker.hermetic | |
| } | |
| } | |
| group("non_hermetic_tests") { | |
| testonly = true | |
| deps = [] | |
| if (defined(invoker.non_hermetic)) { | |
| deps += invoker.non_hermetic | |
| } | |
| } | |
| } | |
| if (is_host) { | |
| group("host_tests") { | |
| testonly = true | |
| deps = [] | |
| if (defined(invoker.host)) { | |
| deps += invoker.host | |
| } | |
| } | |
| if (has_board) { | |
| group("e2e_tests") { | |
| testonly = true | |
| deps = [] | |
| if (defined(invoker.e2e)) { | |
| deps += invoker.e2e | |
| } | |
| } | |
| } | |
| } | |
| } | |
| # Creates standardized tests groups that are collections of the standardized | |
| # test groups in child areas of the tree. | |
| # | |
| # This creates the following test groups: | |
| # | |
| # ':hermetic_tests' - A group which only contains hermetic tests, and only | |
| # exists in the default toolchain. | |
| # ':host_tests' - A group which only contains host tests, and only exists in | |
| # the host toolchain. | |
| # ':e2e_tests' - A group which only contains end-to-end tests, and only exists | |
| # in the host toolchain | |
| # ':non_hermetic_tests' - A group which only contains non-hermetic integration | |
| # tests, and only exists in the default toolchain | |
| # | |
| # The template takes a single parameter: | |
| # | |
| # areas | |
| # [list, GN labels] - The list of GN labels to instances of the | |
| # `standardized_test_groups()` GN template. These labels are normalized, the | |
| # appropriate suffixes added, and then made deps of the standardized test | |
| # groups created by this template. | |
| # | |
| # Example: | |
| # | |
| # areas = [ "//src/foo/bar:tests"] | |
| # | |
| # will add "//src/foo/bar:hermetic_tests" to the ":hermetic_tests" group that | |
| # is created by this template. "//src/foo/bar:non_hermetic_tests" will be | |
| # added to the ":non_hermetic_tests" group and so on. | |
| # | |
| # DO NOT SPECIFY ANY TOOLCHAIN! Any toolchain that's specified will be | |
| # stripped and only the correct toolchain will be used (implicitly). | |
| # | |
| template("standardized_test_groups_collection") { | |
| areas = [] | |
| if (defined(invoker.areas)) { | |
| foreach(area, invoker.areas) { | |
| label = get_label_info(area, "dir") | |
| areas += [ label ] | |
| } | |
| } | |
| if (current_toolchain == default_toolchain) { | |
| group("hermetic_tests") { | |
| testonly = true | |
| deps = [] | |
| foreach(area, areas) { | |
| deps += "${area}:${target_name}" | |
| } | |
| } | |
| group("non_hermetic_tests") { | |
| testonly = true | |
| deps = [] | |
| foreach(area, areas) { | |
| deps += "${area}:${target_name}" | |
| } | |
| } | |
| } | |
| if (is_host) { | |
| group("host_tests") { | |
| testonly = true | |
| deps = [] | |
| foreach(area, areas) { | |
| deps += "${area}:${target_name}" | |
| } | |
| } | |
| if (has_board) { | |
| group("e2e_tests") { | |
| testonly = true | |
| deps = [] | |
| foreach(area, areas) { | |
| deps += "${area}:${target_name}" | |
| } | |
| } | |
| } | |
| } | |
| } |