Skip to content

Commit

Permalink
Expose the dart kernel snapshot target and copied assets as a public …
Browse files Browse the repository at this point in the history
…dependency (#16266)

This allows for targets to depend on the assets generated by the test_fixtures target.
  • Loading branch information
George Wright committed Feb 4, 2020
1 parent 7e1d144 commit 4cda916
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions testing/testing.gni
Expand Up @@ -162,7 +162,8 @@ template("dart_snapshot") {
dart_kernel = dart_snapshot_kernel_path
}

snapshot_deps = [ ":$dart_snapshot_kernel_target_name" ]
snapshot_deps = []
snapshot_public_deps = [ ":$dart_snapshot_kernel_target_name" ]

if (is_aot_test) {
dart_snapshot_aot_target_name = "dart_snapshot_aot_$target_name"
Expand All @@ -177,8 +178,8 @@ template("dart_snapshot") {

group(target_name) {
testonly = true

deps = snapshot_deps
public_deps = snapshot_public_deps
}
}

Expand Down Expand Up @@ -218,6 +219,12 @@ template("copy_fixtures") {
# unused invoker scope error. In such cases specify the fixtures using an empty
# array.
#
# The targets which generate the outputs from these test fixtures (e.g. the
# Dart kernel snapshot) are exposed as public dependencies of the test fixture
# target. This is so that users can depend on the test fixture target directly
# and be able to access the generated outputs without needing to know about the
# internal dependency structure generated by this template.
#
# Arguments:
#
# fixtures (optional): The list of test fixtures. An empty list may be
Expand All @@ -237,14 +244,15 @@ template("test_fixtures") {
}
}
test_deps = [ ":$fixtures_location_target_name" ]
test_public_deps = []

# If the fixtures are specified, copy them to the assets directory.
if (defined(invoker.fixtures)) {
copy_fixtures_target_name = "copy_fixtures_$target_name"
copy_fixtures(copy_fixtures_target_name) {
fixtures = invoker.fixtures
}
test_deps += [ ":$copy_fixtures_target_name" ]
test_public_deps += [ ":$copy_fixtures_target_name" ]
}

# If a Dart file is specified, snapshot it and place it in the generated
Expand All @@ -254,11 +262,12 @@ template("test_fixtures") {
dart_snapshot(dart_snapshot_target_name) {
dart_main = invoker.dart_main
}
test_deps += [ ":$dart_snapshot_target_name" ]
test_public_deps += [ ":$dart_snapshot_target_name" ]
}

group(target_name) {
testonly = true
deps = test_deps
public_deps = test_public_deps
}
}

0 comments on commit 4cda916

Please sign in to comment.