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. |
11 # Variable: | 11 # Variable: |
12 # use_raw_android_executable: Use executable() rather than android_apk(). | 12 # use_raw_android_executable: Use executable() rather than android_apk(). |
13 template("test") { | 13 template("test") { |
14 if (is_android) { | 14 if (is_android) { |
15 import("//build/config/android/config.gni") | 15 import("//build/config/android/config.gni") |
16 import("//build/config/android/rules.gni") | 16 import("//build/config/android/rules.gni") |
17 | 17 |
18 _use_raw_android_executable = defined(invoker.use_raw_android_executable) && | 18 _use_raw_android_executable = defined(invoker.use_raw_android_executable) && |
19 invoker.use_raw_android_executable | 19 invoker.use_raw_android_executable |
20 | 20 |
21 # 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 |
22 # packages to still produce unique runner scripts. | 22 # packages to still produce unique runner scripts. |
23 _output_name = invoker.target_name | 23 _output_name = invoker.target_name |
24 if (defined(invoker.output_name)) { | 24 if (defined(invoker.output_name)) { |
25 _output_name = invoker.output_name | 25 _output_name = invoker.output_name |
26 } | 26 } |
27 | 27 |
| 28 _test_runner_target = "${_output_name}__test_runner_script" |
28 _wrapper_script_vars = [ | 29 _wrapper_script_vars = [ |
29 "isolate_file", | 30 "isolate_file", |
30 "shard_timeout", | 31 "shard_timeout", |
31 ] | 32 ] |
32 | 33 |
33 if (_use_raw_android_executable) { | 34 if (_use_raw_android_executable) { |
34 _exec_target = "${target_name}__exec" | 35 _exec_target = "${target_name}__exec" |
35 _dist_target = "${target_name}__dist" | 36 _dist_target = "${target_name}__dist" |
36 _exec_output = | 37 _exec_output = |
37 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" | 38 "$target_out_dir/${invoker.target_name}/${invoker.target_name}" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 unittest_apk(_apk_target) { | 99 unittest_apk(_apk_target) { |
99 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) | 100 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ]) |
100 unittests_dep = ":$_library_target" | 101 unittests_dep = ":$_library_target" |
101 apk_name = invoker.target_name | 102 apk_name = invoker.target_name |
102 if (defined(invoker.output_name)) { | 103 if (defined(invoker.output_name)) { |
103 apk_name = invoker.output_name | 104 apk_name = invoker.output_name |
104 unittests_binary = "lib${apk_name}.so" | 105 unittests_binary = "lib${apk_name}.so" |
105 install_script_name = "install_${invoker.output_name}" | 106 install_script_name = "install_${invoker.output_name}" |
106 } | 107 } |
107 deps += [ ":$_library_target" ] | 108 deps += [ ":$_library_target" ] |
| 109 |
| 110 # TODO(agrieve): Remove this data_dep once bots don't build the _apk |
| 111 # target (post-GYP). |
| 112 # It's a bit backwards for the apk to depend on the runner script, since |
| 113 # the apk is conceptually a runtime_dep of the script. However, it is |
| 114 # currently necessary because the bots build this _apk target directly |
| 115 # rather than the group() below. |
| 116 data_deps = [ |
| 117 ":$_test_runner_target", |
| 118 ] |
108 } | 119 } |
109 | 120 |
110 # Incremental test targets work only for .apks. | 121 # Incremental test targets work only for .apks. |
111 _incremental_test_runner_target = | 122 _incremental_test_runner_target = |
112 "${_output_name}_incremental__test_runner_script" | 123 "${_output_name}_incremental__test_runner_script" |
113 test_runner_script(_incremental_test_runner_target) { | 124 test_runner_script(_incremental_test_runner_target) { |
114 forward_variables_from(invoker, _wrapper_script_vars) | 125 forward_variables_from(invoker, _wrapper_script_vars) |
115 apk_target = ":$_apk_target" | 126 apk_target = ":$_apk_target" |
116 test_name = "${_output_name}_incremental" | 127 test_name = "${_output_name}_incremental" |
117 test_type = "gtest" | 128 test_type = "gtest" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 # TODO(GYP): Delete this after we've converted everything to GN. | 237 # TODO(GYP): Delete this after we've converted everything to GN. |
227 # The _run targets exist only for compatibility with GYP. | 238 # The _run targets exist only for compatibility with GYP. |
228 group("${target_name}_run") { | 239 group("${target_name}_run") { |
229 testonly = true | 240 testonly = true |
230 deps = [ | 241 deps = [ |
231 ":${invoker.target_name}", | 242 ":${invoker.target_name}", |
232 ] | 243 ] |
233 } | 244 } |
234 } | 245 } |
235 } | 246 } |
OLD | NEW |