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 |
9 # Define a test as an executable (or apk on Android) with the "testonly" flag | 59 # Define a test as an executable (or apk on Android) with the "testonly" flag |
10 # set. | 60 # set. |
11 # Variable: | 61 # Variable: |
12 # use_raw_android_executable: Use executable() rather than android_apk(). | 62 # use_raw_android_executable: Use executable() rather than android_apk(). |
13 template("test") { | 63 template("test") { |
14 if (is_android) { | 64 if (is_android) { |
15 import("//build/config/android/config.gni") | 65 import("//build/config/android/config.gni") |
16 import("//build/config/android/rules.gni") | 66 import("//build/config/android/rules.gni") |
17 | 67 |
18 _use_raw_android_executable = defined(invoker.use_raw_android_executable) && | 68 _use_raw_android_executable = defined(invoker.use_raw_android_executable) && |
19 invoker.use_raw_android_executable | 69 invoker.use_raw_android_executable |
20 | 70 |
21 # output_name is used to allow targets with the same name but in different | 71 # output_name is used to allow targets with the same name but in different |
22 # packages to still produce unique runner scripts. | 72 # packages to still produce unique runner scripts. |
23 _output_name = invoker.target_name | 73 _output_name = invoker.target_name |
24 if (defined(invoker.output_name)) { | 74 if (defined(invoker.output_name)) { |
25 _output_name = invoker.output_name | 75 _output_name = invoker.output_name |
26 } | 76 } |
27 | 77 |
28 _test_runner_target = "${_output_name}__test_runner_script" | 78 _test_runner_target = "${_output_name}__test_runner_script" |
29 _wrapper_script_vars = [ | 79 _wrapper_script_vars = [ |
30 "isolate_file", | 80 "isolate_file", |
31 "shard_timeout", | 81 "shard_timeout", |
32 ] | 82 ] |
| 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 } |
33 | 113 |
34 if (_use_raw_android_executable) { | 114 if (_use_raw_android_executable) { |
35 _exec_target = "${target_name}__exec" | 115 _exec_target = "${target_name}__exec" |
36 _dist_target = "${target_name}__dist" | 116 _dist_target = "${target_name}__dist" |
37 _exec_output = | 117 _exec_output = |
38 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" | 118 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" |
39 | 119 |
40 executable(_exec_target) { | 120 executable(_exec_target) { |
41 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. | 121 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. |
42 configs = [] | 122 configs = [] |
43 data_deps = [] | 123 data_deps = [] |
44 forward_variables_from(invoker, "*", [ "extra_dist_files" ]) | 124 forward_variables_from( |
| 125 invoker, |
| 126 "*", |
| 127 _wrapper_script_vars + _gen_isolate_vars + [ "extra_dist_files" ]) |
45 testonly = true | 128 testonly = true |
46 | 129 |
47 # Thanks to the set_defaults() for test(), configs are initialized with | 130 # Thanks to the set_defaults() for test(), configs are initialized with |
48 # the default shared_library configs rather than executable configs. | 131 # the default shared_library configs rather than executable configs. |
49 configs -= [ | 132 configs -= [ |
50 "//build/config:shared_library_config", | 133 "//build/config:shared_library_config", |
51 "//build/config/android:hide_native_jni_exports", | 134 "//build/config/android:hide_native_jni_exports", |
52 ] | 135 ] |
53 configs += [ "//build/config:executable_config" ] | 136 configs += [ "//build/config:executable_config" ] |
54 | 137 |
(...skipping 24 matching lines...) Expand all Loading... |
79 "use_default_launcher", | 162 "use_default_launcher", |
80 "write_asset_list", | 163 "write_asset_list", |
81 ] | 164 ] |
82 shared_library(_library_target) { | 165 shared_library(_library_target) { |
83 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. | 166 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. |
84 configs = [] # Prevent list overwriting warning. | 167 configs = [] # Prevent list overwriting warning. |
85 configs = invoker.configs | 168 configs = invoker.configs |
86 testonly = true | 169 testonly = true |
87 | 170 |
88 deps = [] | 171 deps = [] |
89 forward_variables_from( | 172 forward_variables_from(invoker, |
90 invoker, | 173 "*", |
91 "*", | 174 _apk_specific_vars + _wrapper_script_vars + |
92 _apk_specific_vars + _wrapper_script_vars + [ "visibility" ]) | 175 _gen_isolate_vars + [ "visibility" ]) |
93 | 176 |
94 if (!defined(invoker.use_default_launcher) || | 177 if (!defined(invoker.use_default_launcher) || |
95 invoker.use_default_launcher) { | 178 invoker.use_default_launcher) { |
96 deps += [ "//testing/android/native_test:native_test_native_code" ] | 179 deps += [ "//testing/android/native_test:native_test_native_code" ] |
97 } | 180 } |
98 } | 181 } |
99 unittest_apk(_apk_target) { | 182 unittest_apk(_apk_target) { |
100 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) | 183 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) |
101 unittests_dep = ":$_library_target" | 184 unittests_dep = ":$_library_target" |
102 apk_name = invoker.target_name | 185 apk_name = invoker.target_name |
(...skipping 13 matching lines...) Expand all Loading... |
116 data_deps = [ | 199 data_deps = [ |
117 ":$_test_runner_target", | 200 ":$_test_runner_target", |
118 ] | 201 ] |
119 } | 202 } |
120 | 203 |
121 # Incremental test targets work only for .apks. | 204 # Incremental test targets work only for .apks. |
122 _incremental_test_runner_target = | 205 _incremental_test_runner_target = |
123 "${_output_name}_incremental__test_runner_script" | 206 "${_output_name}_incremental__test_runner_script" |
124 test_runner_script(_incremental_test_runner_target) { | 207 test_runner_script(_incremental_test_runner_target) { |
125 forward_variables_from(invoker, _wrapper_script_vars) | 208 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 } |
126 apk_target = ":$_apk_target" | 215 apk_target = ":$_apk_target" |
127 test_name = "${_output_name}_incremental" | 216 test_name = "${_output_name}_incremental" |
128 test_type = "gtest" | 217 test_type = "gtest" |
129 test_suite = _output_name | 218 test_suite = _output_name |
130 incremental_install = true | 219 incremental_install = true |
131 } | 220 } |
132 group("${target_name}_incremental") { | 221 group("${target_name}_incremental") { |
133 testonly = true | 222 testonly = true |
134 datadeps = [ | 223 datadeps = [ |
135 ":$_incremental_test_runner_target", | 224 ":$_incremental_test_runner_target", |
136 ] | 225 ] |
137 deps = [ | 226 deps = [ |
138 ":${_apk_target}_incremental", | 227 ":${_apk_target}_incremental", |
139 ] | 228 ] |
140 } | 229 } |
141 } | 230 } |
142 | 231 |
143 _test_runner_target = "${_output_name}__test_runner_script" | 232 _test_runner_target = "${_output_name}__test_runner_script" |
144 test_runner_script(_test_runner_target) { | 233 test_runner_script(_test_runner_target) { |
145 forward_variables_from(invoker, _wrapper_script_vars) | 234 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 |
146 if (_use_raw_android_executable) { | 242 if (_use_raw_android_executable) { |
147 executable_dist_dir = "$root_out_dir/$_dist_target" | 243 executable_dist_dir = "$root_out_dir/$_dist_target" |
148 } else { | 244 } else { |
149 apk_target = ":$_apk_target" | 245 apk_target = ":$_apk_target" |
150 } | 246 } |
151 test_name = _output_name | 247 test_name = _output_name |
152 test_type = "gtest" | 248 test_type = "gtest" |
153 test_suite = _output_name | 249 test_suite = _output_name |
154 } | 250 } |
155 | 251 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 # TODO(GYP): Delete this after we've converted everything to GN. | 333 # TODO(GYP): Delete this after we've converted everything to GN. |
238 # The _run targets exist only for compatibility with GYP. | 334 # The _run targets exist only for compatibility with GYP. |
239 group("${target_name}_run") { | 335 group("${target_name}_run") { |
240 testonly = true | 336 testonly = true |
241 deps = [ | 337 deps = [ |
242 ":${invoker.target_name}", | 338 ":${invoker.target_name}", |
243 ] | 339 ] |
244 } | 340 } |
245 } | 341 } |
246 } | 342 } |
OLD | NEW |