OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # ============================================================================== | 5 # ============================================================================== |
6 # TEST SETUP | 6 # TEST SETUP |
7 # ============================================================================== | 7 # ============================================================================== |
8 | 8 |
9 template("_gen_isolate") { | |
10 testonly = true | |
11 _runtime_deps_file = "$target_gen_dir/$target_name.runtime_deps" | |
12 group("${target_name}__write_deps") { | |
13 forward_variables_from(invoker, | |
14 [ | |
15 "data", | |
16 "data_deps", | |
17 "deps", | |
18 "public_deps", | |
19 ]) | |
20 write_runtime_deps = _runtime_deps_file | |
21 } | |
22 | |
23 action(target_name) { | |
24 script = "//testing/generate_isolate.py" | |
25 outputs = [ | |
26 invoker.output, | |
27 ] | |
28 args = [ | |
29 "--output-directory=.", | |
30 "--out-file", | |
31 rebase_path(invoker.output, root_build_dir), | |
32 "--runtime-deps-file", | |
33 rebase_path(_runtime_deps_file, root_build_dir), | |
34 ] | |
35 if (is_android) { | |
36 args += [ "--apply-android-filters" ] | |
37 } | |
38 if (defined(invoker.apply_device_filters) && invoker.apply_device_filters) { | |
39 args += [ "--apply-device-filters" ] | |
40 } | |
41 _assert_no_odd_data = | |
42 defined(invoker.assert_no_odd_data) && invoker.assert_no_odd_data | |
43 if (_assert_no_odd_data) { | |
44 args += [ "--assert-no-odd-data" ] | |
45 } | |
46 if (defined(invoker.command)) { | |
47 _isolate_dir = get_path_info(invoker.output, "dir") | |
48 args += [ | |
49 "--command", | |
50 rebase_path(invoker.command, _isolate_dir), | |
51 ] | |
52 } | |
53 deps = [ | |
54 ":${invoker.target_name}__write_deps", | |
55 ] | |
56 } | |
57 } | |
58 | |
59 # Define a test as an executable (or apk on Android) with the "testonly" flag | 9 # Define a test as an executable (or apk on Android) with the "testonly" flag |
60 # set. | 10 # set. |
61 # Variable: | 11 # Variable: |
62 # use_raw_android_executable: Use executable() rather than android_apk(). | 12 # use_raw_android_executable: Use executable() rather than android_apk(). |
63 template("test") { | 13 template("test") { |
64 if (is_android) { | 14 if (is_android) { |
65 import("//build/config/android/config.gni") | 15 import("//build/config/android/config.gni") |
66 import("//build/config/android/rules.gni") | 16 import("//build/config/android/rules.gni") |
67 | 17 |
68 _use_raw_android_executable = defined(invoker.use_raw_android_executable) && | 18 _use_raw_android_executable = defined(invoker.use_raw_android_executable) && |
69 invoker.use_raw_android_executable | 19 invoker.use_raw_android_executable |
70 | 20 |
71 # output_name is used to allow targets with the same name but in different | 21 # output_name is used to allow targets with the same name but in different |
72 # packages to still produce unique runner scripts. | 22 # packages to still produce unique runner scripts. |
73 _output_name = invoker.target_name | 23 _output_name = invoker.target_name |
74 if (defined(invoker.output_name)) { | 24 if (defined(invoker.output_name)) { |
75 _output_name = invoker.output_name | 25 _output_name = invoker.output_name |
76 } | 26 } |
77 | 27 |
78 _test_runner_target = "${_output_name}__test_runner_script" | 28 _test_runner_target = "${_output_name}__test_runner_script" |
79 _wrapper_script_vars = [ | 29 _wrapper_script_vars = [ |
80 "isolate_file", | 30 "isolate_file", |
81 "shard_timeout", | 31 "shard_timeout", |
82 ] | 32 ] |
83 _gen_isolate_vars = [ | |
84 "allow_odd_runtime_deps", | |
85 "ignore_all_data_deps", | |
86 ] | |
87 | |
88 # TODO(agrieve): Delete all manually passed-in .isolate files now that they | |
89 # are unused. http://crbug.com/589318 | |
90 assert(!defined(invoker.isolate_file) || invoker.isolate_file != "") # Mark
used. | |
91 _generate_device_isolate = | |
92 !defined(invoker.ignore_all_data_deps) || !invoker.ignore_all_data_deps | |
93 | |
94 if (_generate_device_isolate) { | |
95 _allow_odd_runtime_deps = defined(invoker.allow_odd_runtime_deps) && | |
96 invoker.allow_odd_runtime_deps | |
97 _device_isolate_path = "$target_gen_dir/$target_name.device.isolate" | |
98 _gen_isolate_target_name = "${target_name}__isolate" | |
99 _gen_isolate(_gen_isolate_target_name) { | |
100 data_deps = [] | |
101 forward_variables_from(invoker, | |
102 [ | |
103 "data", | |
104 "data_deps", | |
105 "deps", | |
106 "public_deps", | |
107 ]) | |
108 assert_no_odd_data = !_allow_odd_runtime_deps | |
109 output = _device_isolate_path | |
110 apply_device_filters = true | |
111 } | |
112 } | |
113 | 33 |
114 if (_use_raw_android_executable) { | 34 if (_use_raw_android_executable) { |
115 _exec_target = "${target_name}__exec" | 35 _exec_target = "${target_name}__exec" |
116 _dist_target = "${target_name}__dist" | 36 _dist_target = "${target_name}__dist" |
117 _exec_output = | 37 _exec_output = |
118 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" | 38 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" |
119 | 39 |
120 executable(_exec_target) { | 40 executable(_exec_target) { |
121 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. | 41 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. |
122 configs = [] | 42 configs = [] |
123 data_deps = [] | 43 data_deps = [] |
124 forward_variables_from( | 44 forward_variables_from(invoker, "*", [ "extra_dist_files" ]) |
125 invoker, | |
126 "*", | |
127 _wrapper_script_vars + _gen_isolate_vars + [ "extra_dist_files" ]) | |
128 testonly = true | 45 testonly = true |
129 | 46 |
130 # Thanks to the set_defaults() for test(), configs are initialized with | 47 # Thanks to the set_defaults() for test(), configs are initialized with |
131 # the default shared_library configs rather than executable configs. | 48 # the default shared_library configs rather than executable configs. |
132 configs -= [ | 49 configs -= [ |
133 "//build/config:shared_library_config", | 50 "//build/config:shared_library_config", |
134 "//build/config/android:hide_native_jni_exports", | 51 "//build/config/android:hide_native_jni_exports", |
135 ] | 52 ] |
136 configs += [ "//build/config:executable_config" ] | 53 configs += [ "//build/config:executable_config" ] |
137 | 54 |
(...skipping 24 matching lines...) Expand all Loading... |
162 "use_default_launcher", | 79 "use_default_launcher", |
163 "write_asset_list", | 80 "write_asset_list", |
164 ] | 81 ] |
165 shared_library(_library_target) { | 82 shared_library(_library_target) { |
166 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. | 83 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. |
167 configs = [] # Prevent list overwriting warning. | 84 configs = [] # Prevent list overwriting warning. |
168 configs = invoker.configs | 85 configs = invoker.configs |
169 testonly = true | 86 testonly = true |
170 | 87 |
171 deps = [] | 88 deps = [] |
172 forward_variables_from(invoker, | 89 forward_variables_from( |
173 "*", | 90 invoker, |
174 _apk_specific_vars + _wrapper_script_vars + | 91 "*", |
175 _gen_isolate_vars + [ "visibility" ]) | 92 _apk_specific_vars + _wrapper_script_vars + [ "visibility" ]) |
176 | 93 |
177 if (!defined(invoker.use_default_launcher) || | 94 if (!defined(invoker.use_default_launcher) || |
178 invoker.use_default_launcher) { | 95 invoker.use_default_launcher) { |
179 deps += [ "//testing/android/native_test:native_test_native_code" ] | 96 deps += [ "//testing/android/native_test:native_test_native_code" ] |
180 } | 97 } |
181 } | 98 } |
182 unittest_apk(_apk_target) { | 99 unittest_apk(_apk_target) { |
183 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) | 100 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) |
184 unittests_dep = ":$_library_target" | 101 unittests_dep = ":$_library_target" |
185 apk_name = invoker.target_name | 102 apk_name = invoker.target_name |
(...skipping 13 matching lines...) Expand all Loading... |
199 data_deps = [ | 116 data_deps = [ |
200 ":$_test_runner_target", | 117 ":$_test_runner_target", |
201 ] | 118 ] |
202 } | 119 } |
203 | 120 |
204 # Incremental test targets work only for .apks. | 121 # Incremental test targets work only for .apks. |
205 _incremental_test_runner_target = | 122 _incremental_test_runner_target = |
206 "${_output_name}_incremental__test_runner_script" | 123 "${_output_name}_incremental__test_runner_script" |
207 test_runner_script(_incremental_test_runner_target) { | 124 test_runner_script(_incremental_test_runner_target) { |
208 forward_variables_from(invoker, _wrapper_script_vars) | 125 forward_variables_from(invoker, _wrapper_script_vars) |
209 if (_generate_device_isolate) { | |
210 isolate_file = _device_isolate_path | |
211 deps = [ | |
212 ":$_gen_isolate_target_name", | |
213 ] | |
214 } | |
215 apk_target = ":$_apk_target" | 126 apk_target = ":$_apk_target" |
216 test_name = "${_output_name}_incremental" | 127 test_name = "${_output_name}_incremental" |
217 test_type = "gtest" | 128 test_type = "gtest" |
218 test_suite = _output_name | 129 test_suite = _output_name |
219 incremental_install = true | 130 incremental_install = true |
220 } | 131 } |
221 group("${target_name}_incremental") { | 132 group("${target_name}_incremental") { |
222 testonly = true | 133 testonly = true |
223 datadeps = [ | 134 datadeps = [ |
224 ":$_incremental_test_runner_target", | 135 ":$_incremental_test_runner_target", |
225 ] | 136 ] |
226 deps = [ | 137 deps = [ |
227 ":${_apk_target}_incremental", | 138 ":${_apk_target}_incremental", |
228 ] | 139 ] |
229 } | 140 } |
230 } | 141 } |
231 | 142 |
232 _test_runner_target = "${_output_name}__test_runner_script" | 143 _test_runner_target = "${_output_name}__test_runner_script" |
233 test_runner_script(_test_runner_target) { | 144 test_runner_script(_test_runner_target) { |
234 forward_variables_from(invoker, _wrapper_script_vars) | 145 forward_variables_from(invoker, _wrapper_script_vars) |
235 if (_generate_device_isolate) { | |
236 isolate_file = _device_isolate_path | |
237 deps = [ | |
238 ":$_gen_isolate_target_name", | |
239 ] | |
240 } | |
241 | |
242 if (_use_raw_android_executable) { | 146 if (_use_raw_android_executable) { |
243 executable_dist_dir = "$root_out_dir/$_dist_target" | 147 executable_dist_dir = "$root_out_dir/$_dist_target" |
244 } else { | 148 } else { |
245 apk_target = ":$_apk_target" | 149 apk_target = ":$_apk_target" |
246 } | 150 } |
247 test_name = _output_name | 151 test_name = _output_name |
248 test_type = "gtest" | 152 test_type = "gtest" |
249 test_suite = _output_name | 153 test_suite = _output_name |
250 } | 154 } |
251 | 155 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 # TODO(GYP): Delete this after we've converted everything to GN. | 237 # TODO(GYP): Delete this after we've converted everything to GN. |
334 # The _run targets exist only for compatibility with GYP. | 238 # The _run targets exist only for compatibility with GYP. |
335 group("${target_name}_run") { | 239 group("${target_name}_run") { |
336 testonly = true | 240 testonly = true |
337 deps = [ | 241 deps = [ |
338 ":${invoker.target_name}", | 242 ":${invoker.target_name}", |
339 ] | 243 ] |
340 } | 244 } |
341 } | 245 } |
342 } | 246 } |
OLD | NEW |