blob: 20ce36994b5454546b7fd5480357703a5566c78e [file] [log] [blame]
# Copyright 2017 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("//topaz/runtime/dart_runner/dart_app.gni")
# Defines a device-side test binary
#
# Bundles a set of `package:test` tests into a single Fuchsia application
# with generated helper code to invoke the tests appropriately.
#
# Parameters
#
# source_dir (optional)
# Directory containing the test sources. Defaults to "test".
#
# deps (optional)
# List of labels for Dart packages this package depends on.
#
# disable_analysis (optional)
# Prevents analysis from being run on this target.
#
# Example of usage:
#
# dart_fuchsia_test("some_tests") {
# tests = [ "test_foo.dart", "test_bar.dart" ]
# }
#
# TODO:
#
# - Implement reporting so that tests can integrate into the waterfall / CQ.
# - Support AOT and Flutter based tests.
# - Get a public API into `package:test` for what we're doing.
#
template("dart_fuchsia_test") {
if (defined(invoker.source_dir)) {
test_source_dir = invoker.source_dir
} else {
test_source_dir = "test"
}
generated_test_main_target = target_name + "__test_main"
generated_test_main = "$target_gen_dir/${target_name}__test_main.dart"
test_helper = "//build/dart/fuchsia_test_helper.dart"
action(generated_test_main_target) {
script = "//build/dart/gen_fuchsia_test_main.py"
inputs = [
test_helper,
]
outputs = [
generated_test_main,
]
args = [
"--out=" + rebase_path(generated_test_main),
"--source-dir=" + rebase_path(test_source_dir),
"--helper=" + rebase_path(test_helper),
]
}
dart_jit_app(target_name) {
forward_variables_from(invoker,
[
"disable_analysis",
])
source_dir = test_source_dir
deps = [
"//third_party/dart-pkg/pub/test",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
non_dart_deps = [ ":$generated_test_main_target($target_toolchain)" ]
if (defined(invoker.non_dart_deps)) {
non_dart_deps += invoker.non_dart_deps
}
main_dart = generated_test_main
extra_analyzer_sources = rebase_path([generated_test_main, test_helper])
}
}