mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
869d9f5285
Updates the test_fixtures rule to support a custom kernel output file name. Improves rule documentation.
90 lines
2.7 KiB
Plaintext
90 lines
2.7 KiB
Plaintext
# Copyright 2013 The Flutter 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("//third_party/dart/build/dart/dart_action.gni")
|
|
|
|
# Builds test fixtures for a unit test.
|
|
#
|
|
# Generates a directory structure containing an assets directory and the Dart
|
|
# code to execute compiled to kernel. Generates:
|
|
# * an asserts directory at `$target_name/assets`.
|
|
# * a C++ implementation for `flutter/testing/testing.h`, defining
|
|
# `testing::GetFixturesPath()`, which returns the assets path.
|
|
# * a kernel snapshot at `$target_name/assets/$kernel_out`.
|
|
#
|
|
# Rule attributes:
|
|
# * fixtures: list of Dart files, including a main entrypoint.
|
|
# * kernel_out: the output path, relative to the assets directory, of the
|
|
# generated kernel snapshot. By default, `kernel_blob.bin`.
|
|
template("test_fixtures") {
|
|
testonly = true
|
|
|
|
assert(defined(invoker.fixtures), "Test fixtures must be specified.")
|
|
kernel_out = "kernel_blob.bin"
|
|
if (defined(invoker.kernel_out)) {
|
|
kernel_out = invoker.kernel_out
|
|
}
|
|
|
|
fixtures_location = "$target_gen_dir/$target_name/assets"
|
|
fixtures_location_file = "$target_gen_dir/$target_name/test_fixtures_location.cc"
|
|
|
|
fixtures_name_target_name = target_name + "_gen_fixtures_name"
|
|
action(fixtures_name_target_name) {
|
|
script = "$flutter_root/testing/build/gen_fixtures_location_symbol.py"
|
|
|
|
outputs = [
|
|
fixtures_location_file,
|
|
]
|
|
|
|
args = [
|
|
"--fixtures_location_file",
|
|
rebase_path(fixtures_location_file),
|
|
"--fixtures_location",
|
|
rebase_path(fixtures_location),
|
|
]
|
|
}
|
|
|
|
fixtures_source_set_target_name = target_name + "_gen_fixtures_source_set"
|
|
source_set(fixtures_source_set_target_name) {
|
|
testonly = true
|
|
sources = [
|
|
fixtures_location_file,
|
|
]
|
|
|
|
deps = [
|
|
":$fixtures_name_target_name",
|
|
]
|
|
}
|
|
|
|
fixtures_kernel_target_name = target_name + "_kernel"
|
|
dart_action(fixtures_kernel_target_name) {
|
|
testonly = true
|
|
script = "$root_out_dir/frontend_server.dart.snapshot"
|
|
|
|
fixture_paths = []
|
|
foreach(fixture, invoker.fixtures) {
|
|
fixture_paths += [ rebase_path(fixture) ]
|
|
}
|
|
inputs = fixture_paths
|
|
outputs = ["$fixtures_location/$kernel_out"]
|
|
|
|
args = [
|
|
"--sdk-root", rebase_path("$root_out_dir/flutter_patched_sdk"),
|
|
"--target", "flutter",
|
|
"--output-dill", rebase_path("$fixtures_location/$kernel_out"),
|
|
] + fixture_paths
|
|
deps = [
|
|
"//third_party/dart/utils/kernel-service:frontend_server"
|
|
]
|
|
}
|
|
|
|
group(target_name) {
|
|
testonly = true
|
|
deps = [
|
|
":$fixtures_kernel_target_name",
|
|
":$fixtures_source_set_target_name",
|
|
]
|
|
}
|
|
}
|