Skip to content

Commit

Permalink
bazel: Mark more targets testonly
Browse files Browse the repository at this point in the history
We mark as testonly some dependencies of the googletest backend of
pw_unit_test. As a result, to successfully build when that backend is
selected, we must mark all targets that transitively depend on
pw_unit_test as testonly.

Bug: b/324116813
Change-Id: I725bd335700ab12b45fba0917e82cb01a3018b35
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/193626
Reviewed-by: Armando Montanez <[email protected]>
Commit-Queue: Ted Pudlik <[email protected]>
  • Loading branch information
tpudlik authored and CQ Bot Account committed Feb 23, 2024
1 parent ea6ef4f commit 277297b
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions pw_build/pigweed.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def pw_cc_perf_test(**kwargs):
kwargs["deps"] = kwargs.get("deps", []) + \
["@pigweed//pw_perf_test:logging_main"]
kwargs["deps"] = kwargs["deps"] + ["@pigweed//targets:pw_assert_backend_impl"]
kwargs["testonly"] = True
native.cc_binary(**kwargs)

def pw_cc_facade(**kwargs):
Expand Down
1 change: 1 addition & 0 deletions pw_log_rpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ cc_library(

cc_library(
name = "test_utils",
testonly = True,
srcs = ["test_utils.cc"],
hdrs = ["pw_log_rpc_private/test_utils.h"],
deps = [
Expand Down
1 change: 1 addition & 0 deletions pw_multisink/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pw_cc_test(

cc_library(
name = "multisink_threaded_test",
testonly = True,
srcs = [
"multisink_threaded_test.cc",
],
Expand Down
1 change: 1 addition & 0 deletions pw_rpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ cc_library(

cc_library(
name = "integration_testing",
testonly = True,
srcs = [
"integration_testing.cc",
],
Expand Down
4 changes: 4 additions & 0 deletions pw_system/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ cc_library(

pw_cc_binary(
name = "system_example",
# This is marked as testonly because the example app pulls in the RPC unit
# test runner. In a real production binary, you wouldn't want to have any
# testonly dependencies.
testonly = True,
srcs = ["example_user_app_init.cc"],
deps = [
":init",
Expand Down
1 change: 1 addition & 0 deletions pw_thread/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ cc_library(
# //pw_thread_stl:thread_backend_test as an example.
cc_library(
name = "thread_facade_test",
testonly = True,
srcs = [
"thread_facade_test.cc",
],
Expand Down
1 change: 1 addition & 0 deletions pw_trace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pw_cc_test(

cc_library(
name = "trace_null_test",
testonly = True,
srcs = [
"trace_null_test.cc",
"trace_null_test_c.c",
Expand Down
2 changes: 2 additions & 0 deletions pw_transfer/integration_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ java_proto_library(

pw_cc_binary(
name = "cpp_client",
testonly = True,
srcs = ["client.cc"],
deps = [
":config_cc_proto",
Expand All @@ -103,6 +104,7 @@ pw_cc_binary(

py_library(
name = "integration_test_fixture",
testonly = True,
srcs = [
"test_fixture.py",
],
Expand Down
17 changes: 17 additions & 0 deletions pw_unit_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ alias(

cc_library(
name = "framework",
testonly = True,
hdrs = ["public/pw_unit_test/framework.h"],
includes = ["public"],
)

cc_library(
name = "light",
testonly = True,
srcs = ["framework_light.cc"],
hdrs = [
"light_public_overrides/pw_unit_test/framework_backend.h",
Expand Down Expand Up @@ -80,6 +82,7 @@ cc_library(

cc_library(
name = "googletest",
testonly = True,
hdrs = [
"googletest_public_overrides/pw_unit_test/framework_backend.h",
],
Expand All @@ -93,13 +96,15 @@ cc_library(
# Identifies when the light framework is being used.
config_setting(
name = "light_setting",
testonly = True,
flag_values = {
"@pigweed//targets:pw_unit_test_backend": "@pigweed//pw_unit_test:light",
},
)

config_setting(
name = "gtest_setting",
testonly = True,
flag_values = {
"@pigweed//targets:pw_unit_test_backend": "@pigweed//pw_unit_test:googletest",
},
Expand Down Expand Up @@ -168,6 +173,7 @@ pw_cc_test(

cc_library(
name = "simple_printing_event_handler",
testonly = True,
srcs = ["simple_printing_event_handler.cc"],
hdrs = [
"public/pw_unit_test/simple_printing_event_handler.h",
Expand All @@ -183,6 +189,7 @@ cc_library(

cc_library(
name = "simple_printing_main",
testonly = True,
srcs = [
"simple_printing_main.cc",
],
Expand All @@ -196,6 +203,7 @@ cc_library(

cc_library(
name = "printf_event_handler",
testonly = True,
hdrs = ["public/pw_unit_test/printf_event_handler.h"],
deps = [
":googletest_style_event_handler",
Expand All @@ -205,6 +213,7 @@ cc_library(

cc_library(
name = "printf_main",
testonly = True,
srcs = ["printf_main.cc"],
deps = [
":printf_event_handler",
Expand All @@ -214,6 +223,7 @@ cc_library(

cc_library(
name = "logging_event_handler",
testonly = True,
srcs = [
"logging_event_handler.cc",
],
Expand All @@ -232,6 +242,7 @@ cc_library(
# Provides logging to either the light framework or an external GoogleTest.
cc_library(
name = "logging",
testonly = True,
deps = [":logging_event_handler"] + select({
":gtest_setting": [":googletest_handler_adapter"],
"//conditions:default": [],
Expand All @@ -240,6 +251,7 @@ cc_library(

pw_cc_binary(
name = "logging_main",
testonly = True,
srcs = [
"logging_main.cc",
],
Expand All @@ -251,6 +263,7 @@ pw_cc_binary(

cc_library(
name = "multi_event_handler",
testonly = True,
hdrs = [
"public/pw_unit_test/multi_event_handler.h",
],
Expand Down Expand Up @@ -289,6 +302,7 @@ pw_proto_library(

cc_library(
name = "rpc_service",
testonly = True,
srcs = ["unit_test_service.cc"] + select({
":light_setting": ["rpc_light_event_handler.cc"],
"//conditions:default": [":rpc_gtest_event_handler.cc"],
Expand Down Expand Up @@ -319,6 +333,7 @@ cc_library(

cc_library(
name = "rpc_main",
testonly = True,
srcs = [
"rpc_main.cc",
],
Expand All @@ -334,6 +349,7 @@ cc_library(

cc_library(
name = "static_library_support",
testonly = True,
srcs = ["static_library_support.cc"],
hdrs = ["public/pw_unit_test/static_library_support.h"],
includes = ["public"],
Expand All @@ -342,6 +358,7 @@ cc_library(

cc_library(
name = "tests_in_archive",
testonly = True,
srcs = [
"static_library_archived_tests.cc",
"static_library_missing_archived_tests.cc",
Expand Down
1 change: 1 addition & 0 deletions pw_work_queue/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cc_library(

cc_library(
name = "work_queue_test",
testonly = True,
srcs = [
"work_queue_test.cc",
],
Expand Down

0 comments on commit 277297b

Please sign in to comment.