| 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 # This file contains templates which are meant to simplify building and | 5 # This file contains templates which are meant to simplify building and |
| 6 # running test binaries with the Chromecast build infrastructure. See | 6 # running test binaries with the Chromecast build infrastructure. See |
| 7 # documentation above each template for specific use. | 7 # documentation above each template for specific use. |
| 8 # | 8 # |
| 9 # Example Usage | 9 # Example Usage |
| 10 # | 10 # |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 # } | 56 # } |
| 57 # | 57 # |
| 58 # # Build this to create build and run lists for bar and foo tests. | 58 # # Build this to create build and run lists for bar and foo tests. |
| 59 # cast_test_group_list("cast_test_lists") { | 59 # cast_test_group_list("cast_test_lists") { |
| 60 # test_groups = [ | 60 # test_groups = [ |
| 61 # ":cast_tests", | 61 # ":cast_tests", |
| 62 # ":external_tests", | 62 # ":external_tests", |
| 63 # ] | 63 # ] |
| 64 # | 64 # |
| 65 # build_list_paths = "$root_out_dir/path/to/test/build_list.txt" | 65 # build_list_paths = "$root_out_dir/path/to/test/build_list.txt" |
| 66 # | |
| 67 # run_list_path = "$root_out_dir/path/to/list/run_list.txt" | 66 # run_list_path = "$root_out_dir/path/to/list/run_list.txt" |
| 67 # runtime_deps_path = "$root_out_dir/path/to/list/runtime_deps.json" |
| 68 # } | 68 # } |
| 69 | 69 |
| 70 import("//testing/test.gni") | 70 import("//testing/test.gni") |
| 71 | 71 |
| 72 # Do not allow mixing of gtests and junit tests. All gtests must go into one | 72 # Do not allow mixing of gtests and junit tests. All gtests must go into one |
| 73 # directory, while all junit tests must go into another directory. | 73 # directory, while all junit tests must go into another directory. |
| 74 _gtest_gen_dir = "$root_gen_dir/chromecast/tests" | 74 _gtest_gen_dir = "$root_gen_dir/chromecast/tests" |
| 75 _junit_gen_dir = "$root_gen_dir/chromecast/junit" | 75 _junit_gen_dir = "$root_gen_dir/chromecast/junit" |
| 76 | 76 |
| 77 # A group of test executables. Including test targets in this group makes it | 77 # A group of test executables. Including test targets in this group makes it |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 # This will be the prefix of each output file. | 194 # This will be the prefix of each output file. |
| 195 _output_prefix = "$_shared_dir/$_priority-$target_name" | 195 _output_prefix = "$_shared_dir/$_priority-$target_name" |
| 196 | 196 |
| 197 # Create a list of all the target names. These must correspond to the name of | 197 # Create a list of all the target names. These must correspond to the name of |
| 198 # the test binary. | 198 # the test binary. |
| 199 _test_names = [] | 199 _test_names = [] |
| 200 foreach(_test, invoker.tests) { | 200 foreach(_test, invoker.tests) { |
| 201 _test_names += [ get_label_info(_test, "name") ] | 201 _test_names += [ get_label_info(_test, "name") ] |
| 202 } | 202 } |
| 203 | 203 |
| 204 # Create a dummy target so that we can get the runtime deps for each test |
| 205 # and output them into a file. The runtime deps include all of the data files, |
| 206 # data directories, and shared libraries that a test needs in order to run. |
| 207 foreach(_test, invoker.tests) { |
| 208 _test_name = get_label_info(_test, "name") |
| 209 group(_test_name + "_cast_runtime_deps") { |
| 210 testonly = true |
| 211 data_deps = [ |
| 212 _test, |
| 213 ] |
| 214 write_runtime_deps = |
| 215 "${_shared_dir}/runtime_deps/${_test_name}_runtime_deps.txt" |
| 216 } |
| 217 } |
| 218 |
| 204 # This action generates a list of target names to build and run. It will be | 219 # This action generates a list of target names to build and run. It will be |
| 205 # depended upon by the "pack_build" action of the cast_test_group_list | 220 # depended upon by the "pack_build" action of the cast_test_group_list |
| 206 # instance which depends on this cast_test_group. | 221 # instance which depends on this cast_test_group. |
| 207 action(target_name + "_create_list") { | 222 action(target_name + "_create_list") { |
| 208 script = "//chromecast/tools/build/generate_test_lists.py" | 223 script = "//chromecast/tools/build/generate_test_lists.py" |
| 209 | 224 |
| 210 outputs = [ | 225 outputs = [ |
| 211 "$_output_prefix.tests", | 226 "$_output_prefix.tests", |
| 212 ] | 227 ] |
| 213 | 228 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 # this target will fail. | 292 # this target will fail. |
| 278 # | 293 # |
| 279 # build_list_path (required) | 294 # build_list_path (required) |
| 280 # The absolute filepath of the output file which will hold the list of | 295 # The absolute filepath of the output file which will hold the list of |
| 281 # tests to be built. | 296 # tests to be built. |
| 282 # | 297 # |
| 283 # run_list_path (required) | 298 # run_list_path (required) |
| 284 # The absolute filepath of the output file which will hold the list of | 299 # The absolute filepath of the output file which will hold the list of |
| 285 # tests to be run, each with filters assigned by cast_groups. | 300 # tests to be run, each with filters assigned by cast_groups. |
| 286 # | 301 # |
| 302 # runtime_deps_path (required) |
| 303 # The absolute filepath of the output file which will hold the json dict |
| 304 # of runtime dependencies for each test to be run. |
| 305 # |
| 287 # additional_options (optional) | 306 # additional_options (optional) |
| 288 # Options which are passed to the python script, and applied to every test | 307 # Options which are passed to the python script, and applied to every test |
| 289 # | 308 # |
| 290 # build_tests (optional) | 309 # build_tests (optional) |
| 291 # Set this to true to build all of the tests included in |test_groups|. | 310 # Set this to true to build all of the tests included in |test_groups|. |
| 292 # Defaults to false. Note that if this is set to true, the test targets | 311 # Defaults to false. Note that if this is set to true, the test targets |
| 293 # will be built after all the lists are generated. | 312 # will be built after all the lists are generated. |
| 294 # test_type (optional) | 313 # test_type (optional) |
| 295 # A string, which must be either "junit" or "gtest". If not defined, | 314 # A string, which must be either "junit" or "gtest". If not defined, |
| 296 # defaults to "gtest". | 315 # defaults to "gtest". |
| 297 # | 316 # |
| 298 template("cast_test_group_list") { | 317 template("cast_test_group_list") { |
| 299 assert(defined(invoker.test_groups), "$target_name needs 'test_groups'") | 318 assert(defined(invoker.test_groups), "$target_name needs 'test_groups'") |
| 300 assert(defined(invoker.run_list_path), "$target_name needs 'run_list_path'") | 319 assert(defined(invoker.run_list_path), "$target_name needs 'run_list_path'") |
| 301 assert(defined(invoker.build_list_path), | 320 assert(defined(invoker.build_list_path), |
| 302 "$target_name needs 'build_list_path'") | 321 "$target_name needs 'build_list_path'") |
| 322 assert(defined(invoker.runtime_deps_path), |
| 323 "$target_name needs 'runtime_deps_path'") |
| 303 | 324 |
| 304 _pack_build_action = target_name + "_pack_build" | 325 _pack_build_action = target_name + "_pack_build" |
| 305 | 326 |
| 306 _test_type = "gtest" | 327 _test_type = "gtest" |
| 307 if (defined(invoker.test_type)) { | 328 if (defined(invoker.test_type)) { |
| 308 assert(invoker.test_type == "gtest" || invoker.test_type == "junit") | 329 assert(invoker.test_type == "gtest" || invoker.test_type == "junit") |
| 309 _test_type = invoker.test_type | 330 _test_type = invoker.test_type |
| 310 } | 331 } |
| 311 | 332 |
| 312 if (_test_type == "gtest") { | 333 if (_test_type == "gtest") { |
| 313 _shared_dir = _gtest_gen_dir | 334 _shared_dir = _gtest_gen_dir |
| 314 } else if (_test_type == "junit") { | 335 } else if (_test_type == "junit") { |
| 315 _shared_dir = _junit_gen_dir | 336 _shared_dir = _junit_gen_dir |
| 316 } | 337 } |
| 317 | 338 |
| 318 # Add the run list to runtime data dependencies | 339 # Add the run list to runtime data dependencies |
| 319 data = [ | 340 data = [ |
| 320 invoker.run_list_path, | 341 invoker.run_list_path, |
| 342 invoker.runtime_deps_path, |
| 321 ] | 343 ] |
| 322 | 344 |
| 323 # Generate a list of the "create_list" actions for each group. These will be | 345 # Generate a list of the "create_list" actions for each group. These will be |
| 324 # depended upon to ensure they're run before the "pack_build" step. | 346 # depended upon to ensure they're run before the "pack_build" step. |
| 325 _build_actions = [] | 347 _build_actions = [] |
| 326 foreach(_test_group, invoker.test_groups) { | 348 foreach(_test_group, invoker.test_groups) { |
| 327 _build_actions += [ _test_group + "_create_list" ] | 349 _build_actions += [ _test_group + "_create_list" ] |
| 328 } | 350 } |
| 329 | 351 |
| 330 # Generate a list of the "filter" actions for each group. These will be | 352 # Generate a list of the "filter" actions for each group. These will be |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 # //chromecast/tools/build/generate_test_lists.py for more information. | 393 # //chromecast/tools/build/generate_test_lists.py for more information. |
| 372 # Note that this target takes the name of the invoker, such that invoking the | 394 # Note that this target takes the name of the invoker, such that invoking the |
| 373 # target runs this step. | 395 # target runs this step. |
| 374 action(target_name) { | 396 action(target_name) { |
| 375 testonly = true | 397 testonly = true |
| 376 | 398 |
| 377 script = "//chromecast/tools/build/generate_test_lists.py" | 399 script = "//chromecast/tools/build/generate_test_lists.py" |
| 378 | 400 |
| 379 outputs = [ | 401 outputs = [ |
| 380 invoker.run_list_path, | 402 invoker.run_list_path, |
| 403 invoker.runtime_deps_path, |
| 381 ] | 404 ] |
| 382 | 405 |
| 383 args = [ | 406 args = [ |
| 384 "-o", | 407 "-o", |
| 385 rebase_path(invoker.run_list_path), | 408 rebase_path(invoker.run_list_path), |
| 409 "-d", |
| 410 rebase_path(invoker.runtime_deps_path), |
| 386 "-t", | 411 "-t", |
| 387 rebase_path(_shared_dir), | 412 rebase_path(_shared_dir), |
| 388 "pack_run", | 413 "pack_run", |
| 389 ] | 414 ] |
| 390 | 415 |
| 391 # Add addtional options if they have been set. | 416 # Add addtional options if they have been set. |
| 392 if (defined(invoker.additional_options)) { | 417 if (defined(invoker.additional_options)) { |
| 393 args += [ "-a" ] | 418 args += [ "-a" ] |
| 394 args += invoker.additional_options | 419 args += invoker.additional_options |
| 395 } | 420 } |
| 396 | 421 |
| 397 # Depend first on the "pack_build" step, so that the build lists are created
. | 422 # Depend first on the "pack_build" step, so that the build lists are created
. |
| 398 deps = [ | 423 deps = [ |
| 399 ":$_pack_build_action", | 424 ":$_pack_build_action", |
| 400 ] | 425 ] |
| 401 | 426 |
| 402 # Next, depend on the filter steps, such that they are created before this | 427 # Next, depend on the filter steps, such that they are created before this |
| 403 # script executes. | 428 # script executes. |
| 404 deps += _filter_actions | 429 deps += _filter_actions |
| 405 | 430 |
| 406 # If |build_tests| has been set to true, depend on the testing targets so | 431 # If |build_tests| has been set to true, depend on the testing targets so |
| 407 # that the tests are built. | 432 # that the tests are built. |
| 408 if (defined(_build_tests)) { | 433 if (defined(_build_tests)) { |
| 409 deps += _build_tests | 434 deps += _build_tests |
| 410 } | 435 } |
| 411 } | 436 } |
| 412 } | 437 } |
| OLD | NEW |