1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 # ==============================================================================
7 # ==============================================================================
9 # Define a test as an executable (or apk on Android) with the "testonly" flag
13 import("//build/config/android/config.gni")
14 import("//build/config/android/rules.gni")
16 main_target_name = target_name
17 library_name = "_${target_name}__library"
18 apk_name = "${target_name}_apk"
20 shared_library(library_name) {
21 # Configs will always be defined since we set_defaults for a component
22 # in the main config. We want to use those rather than whatever came with
23 # the nested shared/static library inside the component.
24 configs = [] # Prevent list overwriting warning.
25 configs = invoker.configs
29 # Don't use "*" to forward all variables since some (like output_name
30 # and isolate_file) apply only to the APK below.
31 forward_variables_from(invoker,
33 "all_dependent_configs",
34 "allow_circular_includes_from",
43 "forward_dependent_configs_from",
58 if (!defined(invoker.use_launcher) || invoker.use_launcher) {
59 deps += [ "//testing/android/native_test:native_test_native_code" ]
61 if (defined(invoker.deps)) {
66 unittest_apk(apk_name) {
67 unittests_dep = ":$library_name"
68 apk_name = main_target_name
69 if (defined(invoker.output_name)) {
70 apk_name = invoker.output_name
71 unittests_binary = "lib${apk_name}.so"
76 if (defined(invoker.apk_deps)) {
77 deps += invoker.apk_deps
79 if (defined(invoker.apk_asset_location)) {
80 asset_location = invoker.apk_asset_location
84 test_name = main_target_name
85 if (defined(invoker.output_name)) {
86 test_name = invoker.output_name
88 test_runner_script_name = "${test_name}__test_runner_script"
89 test_runner_script(test_runner_script_name) {
92 test_suite = test_name
93 if (defined(invoker.isolate_file)) {
94 isolate_file = invoker.isolate_file
101 ":$test_runner_script_name",
110 import("//build/config/ios/rules.gni")
113 target__sources_name = "${target_name}__sources"
114 if (defined(invoker.sources)) {
115 source_set(target__sources_name) {
116 sources = invoker.sources
119 configs = [] # Prevent list overwriting warning.
120 configs += invoker.configs
122 forward_variables_from(invoker,
140 ios_app(target_name) {
141 # TODO(GYP): Make this configurable and only provide a default
142 # that can be overridden.
143 info_plist = "//testing/gtest_ios/unittest-Info.plist"
144 app_name = target_name
145 entitlements_path = "//testing/gtest_ios"
146 code_signing_identity = ""
150 set_sources_assignment_filter([])
152 forward_variables_from(invoker,
154 "all_dependent_configs",
155 "allow_circular_includes_from",
162 "forward_dependent_configs_from",
173 if (defined(invoker.deps)) {
179 # All shared libraries must have the sanitizer deps to properly link in
180 # asan mode (this target will be empty in other cases).
181 "//build/config/sanitizers:deps",
184 if (defined(invoker.sources)) {
185 deps += [ ":${target__sources_name}" ]
189 executable(target_name) {
190 forward_variables_from(invoker, "*")
194 if (!defined(invoker.deps)) {
198 # All shared libraries must have the sanitizer deps to properly link in
199 # asan mode (this target will be empty in other cases).
200 "//build/config/sanitizers:deps",
202 # Give tests the default manifest on Windows (a no-op elsewhere).
203 "//build/win:default_exe_manifest",