Skip to content

Commit 823a6cb

Browse files
committed
Implicitly add :gtest and :gtest_main dependencies to cf_cc_test targets
Every target includes these dependencies manually, changing it to be implicit adds some convenience to defining new test targets and reduces clutter. Bug: b/503084517
1 parent b69c667 commit 823a6cb

27 files changed

Lines changed: 14 additions & 145 deletions

File tree

base/cvd/cuttlefish/bazel/rules.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ cf_cc_library = macro(
7070
implementation = _cf_cc_library_implementation,
7171
)
7272

73-
def _cf_cc_test_implementation(name, clang_tidy_enabled, copts, **kwargs):
73+
def _cf_cc_test_implementation(name, clang_tidy_enabled, copts, deps, **kwargs):
7474
if not clang_tidy_enabled and not kwargs["deprecation"]:
7575
kwargs["deprecation"] = "Not covered by clang-tidy"
7676
cc_test(
7777
name = name,
7878
copts = (copts or []) + COPTS,
79+
deps = deps + [
80+
"@googletest//:gtest",
81+
"@googletest//:gtest_main",
82+
],
7983
**kwargs,
8084
)
8185
if clang_tidy_enabled:
@@ -91,6 +95,7 @@ cf_cc_test = macro(
9195
attrs = {
9296
"clang_tidy_enabled": attr.bool(configurable = False, default = True, doc = "Decide if a corresponding clang_tidy_test target is generated"),
9397
"copts": attr.string_list(configurable = False, default = []),
98+
"deps": attr.label_list(configurable = False),
9499
},
95100
implementation = _cf_cc_test_implementation,
96101
)

base/cvd/cuttlefish/common/libs/fs/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ cf_cc_test(
5151
deps = [
5252
":fs",
5353
"//libbase",
54-
"@googletest//:gtest",
55-
"@googletest//:gtest_main",
5654
],
5755
)
5856

base/cvd/cuttlefish/common/libs/key_equals_value/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,5 @@ cf_cc_test(
2323
"//cuttlefish/common/libs/key_equals_value",
2424
"//cuttlefish/result",
2525
"//cuttlefish/result:result_matchers",
26-
"@googletest//:gtest",
27-
"@googletest//:gtest_main",
2826
],
2927
)

base/cvd/cuttlefish/common/libs/utils/BUILD.bazel

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ cf_cc_test(
3636
"//cuttlefish/common/libs/utils:base64",
3737
"//cuttlefish/result:result_matchers",
3838
"//cuttlefish/result:result_type",
39-
"@googletest//:gtest",
40-
"@googletest//:gtest_main",
4139
],
4240
)
4341

@@ -142,8 +140,6 @@ cf_cc_test(
142140
"//cuttlefish/result",
143141
"//cuttlefish/result:result_matchers",
144142
"//libbase",
145-
"@googletest//:gtest",
146-
"@googletest//:gtest_main",
147143
],
148144
)
149145

@@ -175,8 +171,6 @@ cf_cc_test(
175171
"//cuttlefish/result",
176172
"//cuttlefish/result:result_matchers",
177173
"//libbase",
178-
"@googletest//:gtest",
179-
"@googletest//:gtest_main",
180174
"@libxml2",
181175
],
182176
)
@@ -251,11 +245,7 @@ cf_cc_library(
251245
cf_cc_test(
252246
name = "network_test",
253247
srcs = ["network_test.cpp"],
254-
deps = [
255-
":network",
256-
"@googletest//:gtest",
257-
"@googletest//:gtest_main",
258-
],
248+
deps = [":network"],
259249
)
260250

261251
cf_cc_library(
@@ -280,8 +270,6 @@ cf_cc_test(
280270
"//cuttlefish/common/libs/utils:contains",
281271
"//cuttlefish/common/libs/utils:proc_file_utils",
282272
"//cuttlefish/result",
283-
"@googletest//:gtest",
284-
"@googletest//:gtest_main",
285273
],
286274
)
287275

@@ -437,8 +425,6 @@ cf_cc_test(
437425
"//cuttlefish/result",
438426
"//libbase",
439427
"@abseil-cpp//absl/log:check",
440-
"@googletest//:gtest",
441-
"@googletest//:gtest_main",
442428
],
443429
)
444430

base/cvd/cuttlefish/host/commands/assemble_cvd/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,6 @@ cf_cc_test(
459459
"//cuttlefish/io",
460460
"//cuttlefish/io:in_memory",
461461
"//cuttlefish/result:result_matchers",
462-
"@googletest//:gtest",
463-
"@googletest//:gtest_main",
464462
],
465463
)
466464

base/cvd/cuttlefish/host/commands/assemble_cvd/android_build/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ cf_cc_test(
9393
"//cuttlefish/host/commands/assemble_cvd/android_build:fake_android_build",
9494
"//cuttlefish/result",
9595
"//cuttlefish/result:result_matchers",
96-
"@googletest//:gtest",
97-
"@googletest//:gtest_main",
9896
],
9997
)
10098

base/cvd/cuttlefish/host/commands/assemble_cvd/boot_image/BUILD.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ cf_cc_test(
4747
"//cuttlefish/io:read_window_view",
4848
"//cuttlefish/io:string",
4949
"//cuttlefish/result:result_matchers",
50-
"@googletest//:gtest",
51-
"@googletest//:gtest_main",
5250
],
5351
)
5452

@@ -93,7 +91,5 @@ cf_cc_test(
9391
"//cuttlefish/io:read_window_view",
9492
"//cuttlefish/io:string",
9593
"//cuttlefish/result:result_matchers",
96-
"@googletest//:gtest",
97-
"@googletest//:gtest_main",
9894
],
9995
)

base/cvd/cuttlefish/host/commands/cvd/cli/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ cf_cc_test(
3535
deps = [
3636
"//cuttlefish/host/commands/cvd/cli:frontline_parser",
3737
"//cuttlefish/result:result_matchers",
38-
"@googletest//:gtest",
39-
"@googletest//:gtest_main",
4038
],
4139
)
4240

base/cvd/cuttlefish/host/commands/cvd/cli/parser/BUILD.bazel

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ cf_cc_test(
6868
"//cuttlefish/host/commands/cvd/cli/parser:cf_configs_common",
6969
"//cuttlefish/host/commands/cvd/cli/parser:test_common",
7070
"//libbase",
71-
"@googletest//:gtest",
72-
"@googletest//:gtest_main",
7371
],
7472
)
7573

@@ -93,8 +91,6 @@ cf_cc_test(
9391
deps = [
9492
"//cuttlefish/host/commands/cvd/cli/parser:test_common",
9593
"//libbase",
96-
"@googletest//:gtest",
97-
"@googletest//:gtest_main",
9894
],
9995
)
10096

@@ -180,8 +176,6 @@ cf_cc_test(
180176
"//cuttlefish/result",
181177
"//cuttlefish/result:result_matchers",
182178
"//libbase",
183-
"@googletest//:gtest",
184-
"@googletest//:gtest_main",
185179
"@jsoncpp",
186180
],
187181
)

base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/BUILD.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ cf_cc_test(
99
srcs = ["boot_configs_test.cc"],
1010
deps = [
1111
"//cuttlefish/host/commands/cvd/cli/parser:test_common",
12-
"@googletest//:gtest",
13-
"@googletest//:gtest_main",
1412
"@jsoncpp",
1513
],
1614
)
@@ -107,8 +105,6 @@ cf_cc_test(
107105
srcs = ["disk_configs_test.cc"],
108106
deps = [
109107
"//cuttlefish/host/commands/cvd/cli/parser:test_common",
110-
"@googletest//:gtest",
111-
"@googletest//:gtest_main",
112108
"@jsoncpp",
113109
],
114110
)
@@ -123,8 +119,6 @@ cf_cc_test(
123119
"//cuttlefish/host/commands/assemble_cvd:launch_cvd_cc_proto",
124120
"//cuttlefish/host/commands/cvd/cli/parser:test_common",
125121
"//cuttlefish/result:result_matchers",
126-
"@googletest//:gtest",
127-
"@googletest//:gtest_main",
128122
"@jsoncpp",
129123
"@protobuf",
130124
"@protobuf//:differencer",
@@ -139,8 +133,6 @@ cf_cc_test(
139133
"//cuttlefish/host/commands/cvd/cli/parser:test_common",
140134
"//cuttlefish/result:result_matchers",
141135
"//libbase",
142-
"@googletest//:gtest",
143-
"@googletest//:gtest_main",
144136
"@jsoncpp",
145137
],
146138
)

0 commit comments

Comments
 (0)