Skip to content

Commit 9319e81

Browse files
bcorsoDagger Team
authored andcommitted
Add a test suite to group our generated functional tests.
This CL adds a test suite to allow running all variants of a test using the it's base name. # Background The macros defined in `test_defs.bzl` generate multiple variants of each test that are built with different javacopts (e.g. Javac vs KSP, Java codegen vs Kotlin codegen, etc.). The name given to the macro (e.g. "BarTest") is currently used as a base name for the actual test targets which have additional suffixes appended to the name (e.g. "BarTest_Javac_JavaCodegen", "BarTest_Ksp_JavaCodegen"). However, one issue with this setup is that it is difficult to run all of the tests associated with "BarTest" since you either need to know all of the variants and run each of then individually, or use `:all` to run all of the targets in the package. This CL adds a test suite using the base name that will run all variants of that test (e.g. `blaze test foo/bar:BarTest`). RELNOTES=N/A PiperOrigin-RevId: 808329922
1 parent 9053b3b commit 9319e81

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test_defs.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def _GenTestsWithVariants(
206206
# Ensure that the source code is compatible with the minimum supported Java version.
207207
javacopts = javacopts + JAVA_RELEASE_MIN
208208

209+
generated_tests = []
209210
for variant in _VARIANTS:
210211
suffix = "_" + variant.backend + "_" + variant.codegen
211212
variant_javacopts = [_JAVACOPTS[variant.backend], _JAVACOPTS[variant.codegen]]
@@ -239,13 +240,14 @@ def _GenTestsWithVariants(
239240
test_deps.append(supporting_files_name)
240241

241242
for test_file in test_files:
242-
test_name = test_file.rsplit(".", 1)[0]
243+
test_name = test_file.rsplit(".", 1)[0] + suffix
243244
test_srcs = [test_file]
245+
generated_tests.append(test_name)
244246

245247
_GenTestWithVariant(
246248
library_rule_type = variant_library_rule_type,
247249
test_rule_type = variant_test_rule_type,
248-
name = test_name + suffix,
250+
name = test_name,
249251
srcs = test_srcs,
250252
tags = tags,
251253
deps = test_deps + variant_deps,
@@ -256,6 +258,13 @@ def _GenTestsWithVariants(
256258
test_kwargs = test_kwargs,
257259
)
258260

261+
# Define the test_suite target with the base name
262+
native.test_suite(
263+
name = name,
264+
tests = generated_tests,
265+
tags = ["manual"], # don't run this suite with /... or :all
266+
)
267+
259268
def _GenLibraryWithVariant(
260269
library_rule_type,
261270
name,

0 commit comments

Comments
 (0)