Chromium Code Reviews| 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 if (is_android) { | |
| 10 template("_gen_apk_isolate") { | |
| 11 action(target_name) { | |
| 12 script = "//build/android/gyp/gen-android-test-isolate.py" | |
| 13 outputs = [ | |
| 14 invoker.output, | |
| 15 ] | |
| 16 args = [ | |
| 17 "--out-file", | |
| 18 rebase_path(invoker.output, root_build_dir), | |
| 19 ".", | |
| 20 invoker.lib_target, | |
| 21 ] | |
| 22 } | |
| 23 } | |
| 24 } | |
| 25 | |
| 9 # Define a test as an executable (or apk on Android) with the "testonly" flag | 26 # Define a test as an executable (or apk on Android) with the "testonly" flag |
| 10 # set. | 27 # set. |
| 28 # | |
| 29 # Variables: | |
| 30 # requires_apk_isolate: Whether the test has files (via data / data_deps) that | |
| 31 # need to be side-loaded to the device. | |
| 11 template("test") { | 32 template("test") { |
| 33 _requires_apk_isolate = | |
|
jbudorick
2016/03/15 20:23:14
Why define this outside of is_android?
agrieve
2016/03/15 20:34:07
I thought it'd be nice to have it live right besid
| |
| 34 defined(invoker.requires_apk_isolate) && invoker.requires_apk_isolate | |
| 35 assert(_requires_apk_isolate || true) # Mark as used. | |
| 36 | |
| 12 if (is_android) { | 37 if (is_android) { |
| 13 import("//build/config/android/config.gni") | 38 import("//build/config/android/config.gni") |
| 14 import("//build/config/android/rules.gni") | 39 import("//build/config/android/rules.gni") |
| 15 | 40 |
| 16 main_target_name = target_name | 41 main_target_name = target_name |
| 17 library_name = "_${target_name}__library" | 42 library_name = "_${target_name}__library" |
| 18 apk_name = "${target_name}_apk" | 43 apk_name = "${target_name}_apk" |
| 19 | 44 |
| 45 if (_requires_apk_isolate) { | |
| 46 _apk_isolate_target_name = "_${target_name}__apk_isolate" | |
| 47 _apk_isolate_path = "$target_gen_dir/$target_name.apk.isolate" | |
| 48 _gen_apk_isolate(_apk_isolate_target_name) { | |
| 49 lib_target = get_label_info(":$library_name", "label_no_toolchain") | |
| 50 output = _apk_isolate_path | |
| 51 } | |
| 52 } | |
| 20 shared_library(library_name) { | 53 shared_library(library_name) { |
| 21 # Configs will always be defined since we set_defaults for a component | 54 # Configs will always be defined since we set_defaults for a component |
| 22 # in the main config. We want to use those rather than whatever came with | 55 # in the main config. We want to use those rather than whatever came with |
| 23 # the nested shared/static library inside the component. | 56 # the nested shared/static library inside the component. |
| 24 configs = [] # Prevent list overwriting warning. | 57 configs = [] # Prevent list overwriting warning. |
| 25 configs = invoker.configs | 58 configs = invoker.configs |
| 26 | 59 |
| 27 testonly = true | 60 testonly = true |
| 28 | 61 |
| 29 # Don't use "*" to forward all variables since some (like output_name | 62 # Don't use "*" to forward all variables since some (like output_name |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 _test_name = main_target_name | 115 _test_name = main_target_name |
| 83 if (defined(invoker.output_name)) { | 116 if (defined(invoker.output_name)) { |
| 84 _test_name = invoker.output_name | 117 _test_name = invoker.output_name |
| 85 } | 118 } |
| 86 test_runner_script_name = "${_test_name}__test_runner_script" | 119 test_runner_script_name = "${_test_name}__test_runner_script" |
| 87 test_runner_script(test_runner_script_name) { | 120 test_runner_script(test_runner_script_name) { |
| 88 apk_target = ":$apk_name" | 121 apk_target = ":$apk_name" |
| 89 test_name = _test_name | 122 test_name = _test_name |
| 90 test_type = "gtest" | 123 test_type = "gtest" |
| 91 test_suite = _test_name | 124 test_suite = _test_name |
| 92 if (defined(invoker.isolate_file)) { | 125 if (_requires_apk_isolate) { |
| 126 isolate_file = _apk_isolate_path | |
| 127 # TODO(agrieve): Delete next conditional once it's not used. | |
| 128 } else if (defined(invoker.isolate_file)) { | |
| 93 isolate_file = invoker.isolate_file | 129 isolate_file = invoker.isolate_file |
| 94 } | 130 } |
| 95 } | 131 } |
| 96 incremental_test_runner_script_name = | 132 incremental_test_runner_script_name = |
| 97 "${_test_name}_incremental__test_runner_script" | 133 "${_test_name}_incremental__test_runner_script" |
| 98 test_runner_script(incremental_test_runner_script_name) { | 134 test_runner_script(incremental_test_runner_script_name) { |
| 99 apk_target = ":$apk_name" | 135 apk_target = ":$apk_name" |
| 100 test_name = "${_test_name}_incremental" | 136 test_name = "${_test_name}_incremental" |
| 101 test_type = "gtest" | 137 test_type = "gtest" |
| 102 test_suite = _test_name | 138 test_suite = _test_name |
| 103 incremental_install = true | 139 incremental_install = true |
| 104 if (defined(invoker.isolate_file)) { | 140 if (_requires_apk_isolate) { |
| 141 isolate_file = _apk_isolate_path | |
| 142 # TODO(agrieve): Delete next conditional once it's not used. | |
| 143 } else if (defined(invoker.isolate_file)) { | |
| 105 isolate_file = invoker.isolate_file | 144 isolate_file = invoker.isolate_file |
| 106 } | 145 } |
| 107 } | 146 } |
| 108 | 147 |
| 109 group(target_name) { | 148 group(target_name) { |
| 110 testonly = true | 149 testonly = true |
| 111 datadeps = [ | 150 data_deps = [ |
| 112 ":$test_runner_script_name", | 151 ":$test_runner_script_name", |
| 113 ] | 152 ] |
| 153 if (_requires_apk_isolate) { | |
| 154 data_deps += [ ":$_apk_isolate_target_name" ] | |
| 155 } | |
| 114 deps = [ | 156 deps = [ |
| 115 ":$apk_name", | 157 ":$apk_name", |
| 116 ] | 158 ] |
| 117 } | 159 } |
| 118 group("${target_name}_incremental") { | 160 group("${target_name}_incremental") { |
| 119 testonly = true | 161 testonly = true |
| 120 datadeps = [ | 162 data_deps = [ |
| 121 ":$incremental_test_runner_script_name", | 163 ":$incremental_test_runner_script_name", |
| 122 ] | 164 ] |
| 165 if (_requires_apk_isolate) { | |
| 166 data_deps += [ ":$_apk_isolate_target_name" ] | |
| 167 } | |
| 123 deps = [ | 168 deps = [ |
| 124 ":${apk_name}_incremental", | 169 ":${apk_name}_incremental", |
| 125 ] | 170 ] |
| 126 } | 171 } |
| 127 | 172 |
| 128 # TODO(GYP): Delete this after we've converted everything to GN. | 173 # TODO(GYP): Delete this after we've converted everything to GN. |
| 129 # The _run targets exist only for compatibility w/ GYP. | 174 # The _run targets exist only for compatibility w/ GYP. |
| 130 group("${target_name}_apk_run") { | 175 group("${target_name}_apk_run") { |
| 131 testonly = true | 176 testonly = true |
| 132 deps = [ | 177 deps = [ |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 # TODO(GYP): Delete this after we've converted everything to GN. | 254 # TODO(GYP): Delete this after we've converted everything to GN. |
| 210 # The _run targets exist only for compatibility with GYP. | 255 # The _run targets exist only for compatibility with GYP. |
| 211 group("${target_name}_run") { | 256 group("${target_name}_run") { |
| 212 testonly = true | 257 testonly = true |
| 213 deps = [ | 258 deps = [ |
| 214 ":$main_target_name", | 259 ":$main_target_name", |
| 215 ] | 260 ] |
| 216 } | 261 } |
| 217 } | 262 } |
| 218 } | 263 } |
| OLD | NEW |