chromium/build/config/ios/ios_test_runner_xcuitest.gni

# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/ios/ios_test_runner_wrapper.gni")
import("//build/config/ios/rules.gni")

# ios_test_runner_xcuitest are just ios_xcuitest_test with an
# ios_test_runner_wrapper. Currently used by Crashpad tests, which do not depend
# on EG2 (and therefore do not use ios_eg2_test)
template("ios_test_runner_xcuitest") {
  assert(defined(invoker.xcode_test_application_name),
         "xcode_test_application_name must be defined for $target_name")
  assert(
      defined(invoker.deps),
      "deps must be defined for $target_name to include at least one xctest" +
          "file.")

  _target_name = target_name
  _test_target = "${target_name}_test"
  ios_xcuitest_test(_test_target) {
    forward_variables_from(invoker,
                           [
                             "xcode_test_application_name",
                             "xctest_bundle_principal_class",
                             "bundle_deps",
                             "deps",
                             "data_deps",
                           ])

    # TODO(crbug.com/40120290) Because we change the target name, the subnodes
    # are going to append with the _test in the naming, which won't be backwards
    # compatible during migration from iOS recipe to Chromium.
    output_name = "${_target_name}"
  }

  ios_test_runner_wrapper(target_name) {
    forward_variables_from(invoker,
                           [
                             "clones",
                             "data",
                             "data_deps",
                             "deps",
                             "executable_args",
                             "retries",
                             "xcode_test_application_name",
                           ])
    _root_build_dir = rebase_path("${root_build_dir}", root_build_dir)

    if (!defined(data_deps)) {
      data_deps = []
    }

    # Include the top ios_test_runner_xcuitest target, and the host app
    data_deps += [ ":${_test_target}" ]

    if (!defined(executable_args)) {
      executable_args = []
    }

    # The xcuitest module is bundled as *-Runner.app, while the host app is
    # bundled as *.app.
    executable_args += [
      "--app",
      "@WrappedPath(${_root_build_dir}/${target_name}-Runner.app)",
    ]
    executable_args += [
      "--host-app",
      "@WrappedPath(${_root_build_dir}/${xcode_test_application_name}.app)",
    ]
  }
}