blob: 4f1418db29bb49850baecb5bbc09c48d00826b01 [file] [log] [blame]
# 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_library.gni")
import("//build/dart/toolchain.gni")
# Defines a Dart test suite
#
# Parameters
#
# sources (optional)
# The list of test files, which must be within source_dir.
# Note: this parameter will soon be mandatory (TO-776).
#
# source_dir (optional)
# Directory containing the test sources. Defaults to "test".
#
# deps (optional)
# List of labels for Dart libraries this suite depends on.
#
# disable_analysis (optional)
# Prevents analysis from being run on this target.
#
# 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
library_target_name = "${target_name}_library"
sources_dir = "test"
if (defined(invoker.source_dir)) {
sources_dir = invoker.source_dir
}
dart_library(library_target_name) {
forward_variables_from(invoker,
[
"deps",
"disable_analysis",
])
infer_package_name = true
source_dir = sources_dir
if (defined(invoker.sources)) {
sources = invoker.sources
}
}
dart_target_gen_dir =
get_label_info(":bogus($dart_toolchain)", "target_gen_dir")
dot_packages_file = "$dart_target_gen_dir/$library_target_name.packages"
fuchsia_tester_label = "//third_party/dart-pkg/git/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 = "//third_party/flutter/shell/testing/($host_toolchain)"
flutter_shell_out_dir = get_label_info(flutter_shell_label, "root_out_dir")
flutter_shell_bin = "$flutter_shell_out_dir/flutter_tester"
if (current_toolchain == host_toolchain) {
invocation_file = "$root_out_dir/$target_name"
} else {
invocation_file = "$target_gen_dir/$target_name"
}
action(main_target_name) {
script = "//build/dart/gen_test_invocation.py"
testonly = true
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 = [
":$library_target_name",
flutter_shell_label,
fuchsia_tester_label,
]
}
}