| # Copyright 2016 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/dart/dart_package.gni") |
| |
| # Defines a Dart test suite |
| # |
| # Parameters |
| # |
| # source_dir (optional) |
| # Directory containing the test sources. Defaults to "test". |
| # |
| # deps (optional) |
| # List of labels for Dart packages this package depends on. |
| # |
| # analysis_options (optional) |
| # By default, a script to run the analyzer on the contents of the package is |
| # generated in the output directory. This parameter contains the path to an |
| # analysis options file for this target. |
| # |
| # disable_analysis (optional) |
| # Prevents the analysis script from being generated. |
| # |
| # Example of usage: |
| # |
| # dart_test("baz_test") { |
| # source_dir = "." |
| # deps = [ |
| # "//foo/baz", |
| # "//third_party/dart-pkg/pub/test", |
| # ] |
| # } |
| template("dart_test") { |
| |
| main_target_name = target_name |
| package_target_name = "${target_name}_package" |
| |
| sources_dir = "test" |
| if (defined(invoker.source_dir)) { |
| sources_dir = invoker.source_dir |
| } |
| |
| dart_package(package_target_name) { |
| forward_variables_from(invoker, [ |
| "analysis_options", |
| "deps", |
| "disable_analysis", |
| ]) |
| |
| infer_package_name = true |
| |
| source_dir = sources_dir |
| } |
| |
| dot_packages_file = "$target_gen_dir/$package_target_name.packages" |
| |
| fuchsia_tester_label = "//lib/flutter/packages/flutter_tools:fuchsia_tester($host_toolchain)" |
| fuchsia_tester_out_dir = get_label_info(fuchsia_tester_label, "root_out_dir") |
| fuchsia_tester_bin = "$fuchsia_tester_out_dir/dart-tools/fuchsia_tester" |
| |
| flutter_shell_label = "//flutter/shell($host_toolchain)" |
| flutter_shell_out_dir = get_label_info(flutter_shell_label, "root_out_dir") |
| flutter_shell_bin = "$flutter_shell_out_dir/flutter_tester" |
| |
| invocation_file = "$target_gen_dir/$target_name.sh" |
| |
| action(main_target_name) { |
| script = "//build/dart/gen_test_invocation.py" |
| |
| outputs = [ |
| invocation_file, |
| ] |
| |
| args = [ |
| "--out", |
| rebase_path(invocation_file), |
| "--source-dir", |
| rebase_path(sources_dir), |
| "--dot-packages", |
| rebase_path(dot_packages_file), |
| "--test-runner", |
| rebase_path(fuchsia_tester_bin), |
| "--flutter-shell", |
| rebase_path(flutter_shell_bin), |
| ] |
| |
| deps = [ |
| ":$package_target_name", |
| flutter_shell_label, |
| fuchsia_tester_label, |
| ] |
| } |
| } |