xref: /aosp_15_r20/external/cronet/build/config/ios/ios_test_runner_xcuitest.gni (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2021 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/ios/ios_test_runner_wrapper.gni")
6import("//build/config/ios/rules.gni")
7
8# ios_test_runner_xcuitest are just ios_xcuitest_test with an
9# ios_test_runner_wrapper. Currently used by Crashpad tests, which do not depend
10# on EG2 (and therefore do not use ios_eg2_test)
11template("ios_test_runner_xcuitest") {
12  assert(defined(invoker.xcode_test_application_name),
13         "xcode_test_application_name must be defined for $target_name")
14  assert(
15      defined(invoker.deps),
16      "deps must be defined for $target_name to include at least one xctest" +
17          "file.")
18
19  _target_name = target_name
20  _test_target = "${target_name}_test"
21  ios_xcuitest_test(_test_target) {
22    forward_variables_from(invoker,
23                           [
24                             "xcode_test_application_name",
25                             "xctest_bundle_principal_class",
26                             "bundle_deps",
27                             "deps",
28                             "data_deps",
29                           ])
30
31    # TODO(crbug.com/1056328) Because we change the target name, the subnodes
32    # are going to append with the _test in the naming, which won't be backwards
33    # compatible during migration from iOS recipe to Chromium.
34    output_name = "${_target_name}"
35  }
36
37  ios_test_runner_wrapper(target_name) {
38    forward_variables_from(invoker,
39                           [
40                             "clones",
41                             "data",
42                             "data_deps",
43                             "deps",
44                             "executable_args",
45                             "retries",
46                             "xcode_test_application_name",
47                           ])
48    _root_build_dir = rebase_path("${root_build_dir}", root_build_dir)
49
50    if (!defined(data_deps)) {
51      data_deps = []
52    }
53
54    # Include the top ios_test_runner_xcuitest target, and the host app
55    data_deps += [ ":${_test_target}" ]
56
57    if (!defined(executable_args)) {
58      executable_args = []
59    }
60
61    # The xcuitest module is bundled as *-Runner.app, while the host app is
62    # bundled as *.app.
63    executable_args += [
64      "--app",
65      "@WrappedPath(${_root_build_dir}/${target_name}-Runner.app)",
66    ]
67    executable_args += [
68      "--host-app",
69      "@WrappedPath(${_root_build_dir}/${xcode_test_application_name}.app)",
70    ]
71  }
72}
73