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 # 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 |
10 # set. | 10 # set. |
(...skipping 10 matching lines...) Expand all Loading... |
21 invoker.use_raw_android_executable | 21 invoker.use_raw_android_executable |
22 | 22 |
23 # output_name is used to allow targets with the same name but in different | 23 # output_name is used to allow targets with the same name but in different |
24 # packages to still produce unique runner scripts. | 24 # packages to still produce unique runner scripts. |
25 _output_name = invoker.target_name | 25 _output_name = invoker.target_name |
26 if (defined(invoker.output_name)) { | 26 if (defined(invoker.output_name)) { |
27 _output_name = invoker.output_name | 27 _output_name = invoker.output_name |
28 } | 28 } |
29 | 29 |
30 _test_runner_target = "${_output_name}__test_runner_script" | 30 _test_runner_target = "${_output_name}__test_runner_script" |
31 _wrapper_script_vars = [ "shard_timeout" ] | 31 _wrapper_script_vars = [ |
32 _gen_isolate_vars = [ | |
33 "allow_odd_runtime_deps", | |
34 "ignore_all_data_deps", | 32 "ignore_all_data_deps", |
| 33 "shard_timeout", |
35 ] | 34 ] |
36 _generate_device_isolate = | |
37 !defined(invoker.ignore_all_data_deps) || !invoker.ignore_all_data_deps | |
38 | |
39 if (_generate_device_isolate) { | |
40 _allow_odd_runtime_deps = defined(invoker.allow_odd_runtime_deps) && | |
41 invoker.allow_odd_runtime_deps | |
42 | |
43 # The device isolate is needed at runtime, so it cannot go in | |
44 # target_gen_dir, as builder/tester configurations do not include it. | |
45 _target_dir_name = get_label_info(":$target_name", "dir") | |
46 _device_isolate_path = "$root_out_dir/gen.runtime/$_target_dir_name/$targe
t_name.device.isolate" | |
47 _gen_isolate_target_name = "${target_name}__isolate" | |
48 device_isolate(_gen_isolate_target_name) { | |
49 forward_variables_from(invoker, | |
50 [ | |
51 "data", | |
52 "data_deps", | |
53 "deps", | |
54 "public_deps", | |
55 ]) | |
56 assert_no_odd_data = !_allow_odd_runtime_deps | |
57 output = _device_isolate_path | |
58 } | |
59 } | |
60 | 35 |
61 assert(_use_raw_android_executable || enable_java_templates) | 36 assert(_use_raw_android_executable || enable_java_templates) |
62 | 37 |
63 if (_use_raw_android_executable) { | 38 if (_use_raw_android_executable) { |
64 _exec_target = "${target_name}__exec" | 39 _exec_target = "${target_name}__exec" |
65 _dist_target = "${target_name}__dist" | 40 _dist_target = "${target_name}__dist" |
66 _exec_output = | 41 _exec_output = |
67 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" | 42 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" |
68 | 43 |
69 executable(_exec_target) { | 44 executable(_exec_target) { |
70 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. | 45 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. |
71 configs = [] | 46 configs = [] |
72 data_deps = [] | 47 data_deps = [] |
73 forward_variables_from( | 48 forward_variables_from(invoker, |
74 invoker, | 49 "*", |
75 "*", | 50 _wrapper_script_vars + [ "extra_dist_files" ]) |
76 _wrapper_script_vars + _gen_isolate_vars + [ "extra_dist_files" ]) | |
77 testonly = true | 51 testonly = true |
78 | 52 |
79 # Thanks to the set_defaults() for test(), configs are initialized with | 53 # Thanks to the set_defaults() for test(), configs are initialized with |
80 # the default shared_library configs rather than executable configs. | 54 # the default shared_library configs rather than executable configs. |
81 configs -= [ | 55 configs -= [ |
82 "//build/config:shared_library_config", | 56 "//build/config:shared_library_config", |
83 "//build/config/android:hide_native_jni_exports", | 57 "//build/config/android:hide_native_jni_exports", |
84 ] | 58 ] |
85 configs += [ "//build/config:executable_config" ] | 59 configs += [ "//build/config:executable_config" ] |
86 | 60 |
(...skipping 28 matching lines...) Expand all Loading... |
115 "write_asset_list", | 89 "write_asset_list", |
116 "use_native_activity", | 90 "use_native_activity", |
117 ] | 91 ] |
118 shared_library(_library_target) { | 92 shared_library(_library_target) { |
119 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. | 93 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn
. |
120 configs = [] # Prevent list overwriting warning. | 94 configs = [] # Prevent list overwriting warning. |
121 configs = invoker.configs | 95 configs = invoker.configs |
122 testonly = true | 96 testonly = true |
123 | 97 |
124 deps = [] | 98 deps = [] |
125 forward_variables_from(invoker, | 99 forward_variables_from( |
126 "*", | 100 invoker, |
127 _apk_specific_vars + _wrapper_script_vars + | 101 "*", |
128 _gen_isolate_vars + [ "visibility" ]) | 102 _apk_specific_vars + _wrapper_script_vars + [ "visibility" ]) |
129 | 103 |
130 if (!defined(invoker.use_default_launcher) || | 104 if (!defined(invoker.use_default_launcher) || |
131 invoker.use_default_launcher) { | 105 invoker.use_default_launcher) { |
132 deps += [ "//testing/android/native_test:native_test_native_code" ] | 106 deps += [ "//testing/android/native_test:native_test_native_code" ] |
133 } | 107 } |
134 } | 108 } |
135 unittest_apk(_apk_target) { | 109 unittest_apk(_apk_target) { |
136 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) | 110 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) |
137 shared_library = ":$_library_target" | 111 shared_library = ":$_library_target" |
138 apk_name = invoker.target_name | 112 apk_name = invoker.target_name |
(...skipping 10 matching lines...) Expand all Loading... |
149 # rather than the group() below. | 123 # rather than the group() below. |
150 data_deps = [ | 124 data_deps = [ |
151 ":$_test_runner_target", | 125 ":$_test_runner_target", |
152 ] | 126 ] |
153 } | 127 } |
154 | 128 |
155 # Incremental test targets work only for .apks. | 129 # Incremental test targets work only for .apks. |
156 _incremental_test_runner_target = | 130 _incremental_test_runner_target = |
157 "${_output_name}_incremental__test_runner_script" | 131 "${_output_name}_incremental__test_runner_script" |
158 test_runner_script(_incremental_test_runner_target) { | 132 test_runner_script(_incremental_test_runner_target) { |
159 forward_variables_from(invoker, _wrapper_script_vars) | 133 forward_variables_from(invoker, |
160 if (_generate_device_isolate) { | 134 _wrapper_script_vars + [ |
161 isolate_file = _device_isolate_path | 135 "data", |
162 deps = [ | 136 "data_deps", |
163 ":$_gen_isolate_target_name", | 137 "deps", |
164 ] | 138 "public_deps", |
165 } | 139 ]) |
166 apk_target = ":$_apk_target" | 140 apk_target = ":$_apk_target" |
167 test_name = "${_output_name}_incremental" | 141 test_name = "${_output_name}_incremental" |
168 test_type = "gtest" | 142 test_type = "gtest" |
169 test_suite = _output_name | 143 test_suite = _output_name |
170 incremental_install = true | 144 incremental_install = true |
171 } | 145 } |
172 group("${target_name}_incremental") { | 146 group("${target_name}_incremental") { |
173 testonly = true | 147 testonly = true |
174 datadeps = [ | 148 datadeps = [ |
175 ":$_incremental_test_runner_target", | 149 ":$_incremental_test_runner_target", |
176 ] | 150 ] |
177 deps = [ | 151 deps = [ |
178 ":${_apk_target}_incremental", | 152 ":${_apk_target}_incremental", |
179 ] | 153 ] |
180 } | 154 } |
181 } | 155 } |
182 | 156 |
183 _test_runner_target = "${_output_name}__test_runner_script" | 157 _test_runner_target = "${_output_name}__test_runner_script" |
184 test_runner_script(_test_runner_target) { | 158 test_runner_script(_test_runner_target) { |
185 forward_variables_from(invoker, _wrapper_script_vars) | 159 forward_variables_from(invoker, |
186 if (_generate_device_isolate) { | 160 _wrapper_script_vars + [ |
187 isolate_file = _device_isolate_path | 161 "data", |
188 deps = [ | 162 "data_deps", |
189 ":$_gen_isolate_target_name", | 163 "deps", |
190 ] | 164 "public_deps", |
191 } | 165 ]) |
192 | 166 |
193 if (_use_raw_android_executable) { | 167 if (_use_raw_android_executable) { |
194 executable_dist_dir = "$root_out_dir/$_dist_target" | 168 executable_dist_dir = "$root_out_dir/$_dist_target" |
195 } else { | 169 } else { |
196 apk_target = ":$_apk_target" | 170 apk_target = ":$_apk_target" |
197 } | 171 } |
198 test_name = _output_name | 172 test_name = _output_name |
199 test_type = "gtest" | 173 test_type = "gtest" |
200 test_suite = _output_name | 174 test_suite = _output_name |
201 } | 175 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 284 } |
311 | 285 |
312 # Test defaults. | 286 # Test defaults. |
313 set_defaults("test") { | 287 set_defaults("test") { |
314 if (is_android) { | 288 if (is_android) { |
315 configs = default_shared_library_configs | 289 configs = default_shared_library_configs |
316 } else { | 290 } else { |
317 configs = default_executable_configs | 291 configs = default_executable_configs |
318 } | 292 } |
319 } | 293 } |
OLD | NEW |