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