blob: 6c609fb85bff8a3fc86e0476b9e0b2aa069f4876 [file]
# Copyright 2026 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.
load("//build/bazel/rules/cc:fx_cc_library.bzl", "fx_cc_library")
load("//build/bazel/rules/cc:fx_cc_test_binary.bzl", "fx_cc_test_binary")
load("//build/bazel/rules/testing:fx_unittest_package.bzl", "fx_unittest_package")
package(default_applicable_licenses = ["//:license"])
test_suite(
name = "tests",
tests = [":loop_fixture_tests"],
visibility = ["//src/lib:__pkg__"],
)
fx_cc_test_binary(
name = "loop_fixture_unittests",
srcs = [
"real_loop_fixture_unittest.cc",
"test_loop_fixture_unittest.cc",
],
deps = [
":loop_fixture",
"//sdk/lib/async:async-cpp",
"//sdk/lib/async-default",
"//sdk/lib/fit-promise",
"//src/lib/fxl:fxl_cli",
"//src/lib/fxl/test:gtest_main",
"//src/lib/fxl/test:test_settings",
"//src/lib/testing/predicates",
"//zircon/system/ulib/sync:sync-cpp",
# Bazel's gtest target bundles gmock; GN's :gmock publicly depends on :gtest.
"@com_google_googletest//:gtest", # @bazel2gn:path_overwrite://third_party/googletest:gmock
],
)
fx_unittest_package(
name = "loop_fixture_tests",
unit_tests = [":loop_fixture_unittests"],
)
# Lets dependents use the shorthand //src/lib/testing/loop_fixture label
# instead of naming the library, which is called :gtest.
alias(
name = "loop_fixture",
actual = ":gtest",
target_compatible_with = ["@platforms//os:fuchsia"],
# Widely used in GN, so GN visibility stays open via raw_overwrite; Bazel
# visibility is limited to actual Bazel dependents.
visibility = [
"//:__subpackages__",
"//src/camera/lib/fake_camera:__pkg__",
"//src/camera/lib/fake_legacy_stream:__pkg__",
"//src/camera/lib/fake_stream:__pkg__",
"//src/developer/build_info:__pkg__",
"//src/sys/activity:__pkg__",
], # @bazel2gn:raw_overwrite:[ "//*" ]
)
# Deprecated - new targets should instead depend on:
# //sdk/lib/testing/loop_fixture (for RealLoop) or
# //src/lib/testing/loop_fixture (for TestLoop or RealLoopFixture)
fx_cc_library(
name = "gtest",
srcs = ["test_loop.cc"],
hdrs = [
"real_loop_fixture.h",
"test_loop.h",
"test_loop_fixture.h",
],
target_compatible_with = ["@platforms//os:fuchsia"],
# Bazel dependents should use the :loop_fixture alias instead.
visibility = [], # @bazel2gn:raw_overwrite:[ "//*" ]
deps = [
"//sdk/lib/async:async-cpp",
"//sdk/lib/async-loop:async-loop-cpp",
"//sdk/lib/async-loop:async-loop-default",
"//sdk/lib/async-loop-testing/cpp",
"//sdk/lib/async-testing",
"//sdk/lib/fit",
"//src/lib/fxl:cli",
"//zircon/system/ulib/zx",
# GN's //third_party/googletest:gtest is testonly, unlike Bazel's, and
# some GN dependents of this library are not testonly.
"@com_google_googletest//:gtest", # @bazel2gn:path_overwrite://third_party/googletest:gtest_no_testonly
],
alwayslink = True,
)