Skip to content

Commit

Permalink
Package fml_unittests in a .far file for fml unit tests on Fuchsia (f…
Browse files Browse the repository at this point in the history
…lutter#13471)

Add fml_tests target for the fml unit tests on Fuchsia
  • Loading branch information
George Wright authored Nov 6, 2019
1 parent 8ebb318 commit bc7a007
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 9 deletions.
5 changes: 5 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ group("flutter") {
]
}
}

# Fuchsia currently only supports a subset of our unit tests
if (is_fuchsia) {
public_deps += [ "$flutter_root/fml:fml_tests" ]
}
}

config("config") {
Expand Down
32 changes: 26 additions & 6 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import("//build/fuchsia/sdk.gni")
import("$flutter_root/testing/testing.gni")

if (is_fuchsia) {
import("$flutter_root/tools/fuchsia/fuchsia_archive.gni")
}

source_set("fml") {
sources = [
"base32.cc",
Expand Down Expand Up @@ -199,26 +203,32 @@ executable("fml_unittests") {
sources = [
"base32_unittest.cc",
"command_line_unittest.cc",
"file_unittest.cc",
"gpu_thread_merger_unittests.cc",
"memory/ref_counted_unittest.cc",
"memory/weak_ptr_unittest.cc",
"message_loop_task_queues_merge_unmerge_unittests.cc",
"message_loop_task_queues_unittests.cc",
"message_loop_unittests.cc",
"message_unittests.cc",
"paths_unittests.cc",
"platform/darwin/string_range_sanitization_unittests.mm",
"synchronization/count_down_latch_unittests.cc",
"synchronization/semaphore_unittest.cc",
"synchronization/waitable_event_unittest.cc",
"thread_local_unittests.cc",
"thread_unittests.cc",
"time/time_delta_unittest.cc",
"time/time_point_unittest.cc",
"time/time_unittest.cc",
]

# TODO(gw280): Figure out why these tests don't work currently on Fuchsia
if (!is_fuchsia) {
sources += [
"file_unittest.cc",
"gpu_thread_merger_unittests.cc",
"message_loop_task_queues_unittests.cc",
"message_loop_unittests.cc",
"synchronization/count_down_latch_unittests.cc",
"thread_unittests.cc",
]
}

deps = [
":fml_fixtures",
"$flutter_root/fml",
Expand All @@ -227,6 +237,16 @@ executable("fml_unittests") {
]
}

if (is_fuchsia) {
fuchsia_test_archive("fml_tests") {
deps = [
":fml_unittests",
]

binary = "fml_unittests"
}
}

executable("fml_benchmarks") {
testonly = true

Expand Down
15 changes: 15 additions & 0 deletions testing/fuchsia/meta/fuchsia_test.cmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"program": {
"binary": "bin/app"
},
"sandbox": {
"features": [
"vulkan",
"deprecated-ambient-replace-as-executable"
],
"services": [
"fuchsia.accessibility.semantics.SemanticsManager",
"fuchsia.sys.Launcher"
]
}
}
26 changes: 23 additions & 3 deletions tools/fuchsia/fuchsia_archive.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("$flutter_root/tools/fuchsia/common_libs.gni")
import("$flutter_root/tools/fuchsia/fuchsia_debug_symbols.gni")

# Creates a Fuchsia archive (.far) file using PM from the Fuchsia SDK.
Expand Down Expand Up @@ -54,13 +55,17 @@ template("fuchsia_archive") {
copy_outputs += [ "$far_base_dir/lib/${lib.name}" ]
}

meta_dir = pkg.meta_dir

cmx_target = "$pkg_target_name.copy_cmx"

if (defined(invoker.cmx_file)) {
cmx_file = invoker.cmx_file
} else {
cmx_file = "${pkg.meta_dir}/${pkg_target_name}.cmx"
}

copy("$cmx_target") {
sources = [
"${meta_dir}/${pkg_target_name}.cmx",
"$cmx_file",
]
outputs = [
"$far_base_dir/meta/{{source_file_part}}",
Expand Down Expand Up @@ -123,3 +128,18 @@ template("fuchsia_archive") {
testonly = pkg_testonly
}
}

template("fuchsia_test_archive") {
fuchsia_archive(target_name) {
testonly = true
libraries = common_libs

assert(defined(invoker.deps), "package must define deps")

deps = invoker.deps
binary = invoker.binary

meta_dir = "$flutter_root/testing/fuchsia/meta"
cmx_file = "$meta_dir/fuchsia_test.cmx"
}
}

0 comments on commit bc7a007

Please sign in to comment.