Update V8 to version 4.6.61.
[chromium-blink-merge.git] / testing / test.gni
blob28a9e550df84865a6d01ef77af4be1e2cc721414
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 # ==============================================================================
6 # TEST SETUP
7 # ==============================================================================
9 # Define a test as an executable (or apk on Android) with the "testonly" flag
10 # set.
11 template("test") {
12   if (is_android) {
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
27       testonly = true
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,
32                              [
33                                "all_dependent_configs",
34                                "allow_circular_includes_from",
35                                "cflags",
36                                "cflags_c",
37                                "cflags_cc",
38                                "check_includes",
39                                "data",
40                                "data_deps",
41                                "datadeps",
42                                "defines",
43                                "forward_dependent_configs_from",
44                                "include_dirs",
45                                "ldflags",
46                                "lib_dirs",
47                                "libs",
48                                "output_extension",
49                                "output_name",
50                                "public",
51                                "public_configs",
52                                "public_deps",
53                                "sources",
54                                "visibility",
55                              ])
57       deps = []
58       if (!defined(invoker.use_launcher) || invoker.use_launcher) {
59         deps += [ "//testing/android/native_test:native_test_native_code" ]
60       }
61       if (defined(invoker.deps)) {
62         deps += invoker.deps
63       }
64     }
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"
72       }
73       deps = [
74         ":$library_name",
75       ]
76       if (defined(invoker.apk_deps)) {
77         deps += invoker.apk_deps
78       }
79       if (defined(invoker.apk_asset_location)) {
80         asset_location = invoker.apk_asset_location
81       }
82     }
84     test_name = main_target_name
85     if (defined(invoker.output_name)) {
86       test_name = invoker.output_name
87     }
88     test_runner_script_name = "${test_name}__test_runner_script"
89     test_runner_script(test_runner_script_name) {
90       test_name = test_name
91       test_type = "gtest"
92       test_suite = test_name
93       if (defined(invoker.isolate_file)) {
94         isolate_file = invoker.isolate_file
95       }
96     }
98     group(target_name) {
99       testonly = true
100       datadeps = [
101         ":$test_runner_script_name",
102       ]
103       deps = [
104         ":$library_name",
105         ":$apk_name",
106       ]
107     }
108   } else if (is_ios) {
109     if (is_ios) {
110       import("//build/config/ios/rules.gni")
111     }
113     target__sources_name = "${target_name}__sources"
114     if (defined(invoker.sources)) {
115       source_set(target__sources_name) {
116         sources = invoker.sources
117         testonly = true
119         configs = []  # Prevent list overwriting warning.
120         configs += invoker.configs
122         forward_variables_from(invoker,
123                                [
124                                  "data",
125                                  "deps",
126                                  "data_deps",
127                                  "datadeps",
128                                  "defines",
129                                  "includes",
130                                ])
131       }
132     }
134     ios_app(target_name) {
135       # TODO(GYP): Make this configurable and only provide a default
136       # that can be overridden.
137       info_plist = "//testing/gtest_ios/unittest-Info.plist"
138       app_name = target_name
139       entitlements_path = "//testing/gtest_ios"
140       code_signing_identity = ""
141       testonly = true
143       # See above call.
144       set_sources_assignment_filter([])
146       forward_variables_from(invoker,
147                              [
148                                "all_dependent_configs",
149                                "allow_circular_includes_from",
150                                "cflags",
151                                "cflags_c",
152                                "cflags_cc",
153                                "cflags_objc",
154                                "cflags_objcc",
155                                "check_includes",
156                                "forward_dependent_configs_from",
157                                "include_dirs",
158                                "ldflags",
159                                "libs",
160                                "output_extension",
161                                "output_name",
162                                "public",
163                                "public_configs",
164                                "public_deps",
165                                "visibility",
166                              ])
168       if (defined(invoker.deps)) {
169         deps = invoker.deps
170       } else {
171         deps = []
172       }
173       deps += [
174         # All shared libraries must have the sanitizer deps to properly link in
175         # asan mode (this target will be empty in other cases).
176         "//build/config/sanitizers:deps",
177       ]
179       if (defined(invoker.sources)) {
180         deps += [ ":${target__sources_name}" ]
181       }
182     }
183   } else {
184     executable(target_name) {
185       forward_variables_from(invoker, "*")
187       testonly = true
189       if (!defined(invoker.deps)) {
190         deps = []
191       }
192       deps += [
193         # All shared libraries must have the sanitizer deps to properly link in
194         # asan mode (this target will be empty in other cases).
195         "//build/config/sanitizers:deps",
197         # Give tests the default manifest on Windows (a no-op elsewhere).
198         "//build/win:default_exe_manifest",
199       ]
200     }
201   }