Skip to content

Commit

Permalink
pw_unit_test: Standardize Bazel interface
Browse files Browse the repository at this point in the history
* Use only //pw_unit_test:pw_unit_test to expose framework.h.
* Provide a dependency on this target automatically to any pw_cc_test.

The latter change is made via an alias, to avoid breaking any users who
already have an explicit dep on this target in their pw_cc_test. (Trying
to remove this dep from the list of deps is unreliable, because the deps
may include select statements.) In subsequent CLs, I'll remove all
explicit deps on //pw_unit_test:pw_unit_test, and clean up the alias.

Bug: 390709187
Change-Id: Id3d18ddfd94e69cb51a4f7ff3485c237b85a0dbf
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/261395
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Armando Montanez <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
Commit-Queue: Ted Pudlik <[email protected]>
Docs-Not-Needed: Ted Pudlik <[email protected]>
  • Loading branch information
tpudlik authored and CQ Bot Account committed Feb 10, 2025
1 parent 17a5e76 commit 7af59d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions pw_unit_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ pw_facade(
deps = [":status_macros"],
)

# TODO: https://pwbug.dev/390709187 - Remove this alias once no pw_cc_test has
# an explicit direct dependency on //pw_unit_test.
alias(
name = "pw_unit_test_alias_for_migration_only",
actual = "pw_unit_test",
)

label_flag(
name = "backend",
build_setting_default = ":light",
Expand All @@ -89,21 +96,16 @@ cc_library(
srcs = ["framework_light.cc"],
hdrs = [
"light_public_overrides/pw_unit_test/framework_backend.h",
# The facade header is included here since
# public_overrides/gtest/gtest.h includes it. This avoids a circular
# dependency in the build system.
"public/pw_unit_test/framework.h",
"public_overrides/gtest/gtest.h",
],
includes = [
"light_public_overrides",
"public",
"public_overrides",
],
deps = [
":config",
":event_handler",
":status_macros",
":pw_unit_test.facade",
"//pw_assert",
"//pw_bytes:alignment",
"//pw_polyfill",
Expand Down
8 changes: 4 additions & 4 deletions pw_unit_test/pw_cc_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def pw_cc_test(**kwargs):
Args:
**kwargs: Passed to cc_test.
"""
kwargs["deps"] = kwargs.get("deps", []) + [str(Label("//pw_build:default_link_extra_lib"))]

# Depend on the backend. E.g. to pull in gtest.h include paths.
kwargs["deps"] = kwargs["deps"] + [str(Label("//pw_unit_test:backend"))]
kwargs["deps"] = kwargs.get("deps", []) + [
str(Label("//pw_build:default_link_extra_lib")),
str(Label("//pw_unit_test:pw_unit_test_alias_for_migration_only")),
]

# Save the base set of deps minus pw_unit_test:main for the .lib target.
original_deps = kwargs["deps"]
Expand Down

0 comments on commit 7af59d4

Please sign in to comment.