Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/private/create_jvm_test_suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def create_jvm_test_suite(

for src in test_srcs:
suffix = src.rfind(".")
test_name = src[:suffix]
test_name = "%s-%s" % (name, src[:suffix])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The src variable can contain path separators (e.g., com/foo/MyTest.java) if the test sources are organized in subdirectories. The current construction of test_name does not account for this, which will result in an invalid target name like my_suite-com/foo/MyTest because target names cannot contain /.

To fix this, you should replace path separators with a valid character like -. This will ensure that generated test names are always valid Bazel target names.

Suggested change
test_name = "%s-%s" % (name, src[:suffix])
test_name = "%s-%s" % (name, src[:suffix].replace("/", "-"))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That aspect doesn't change in this PR, will leave it to maintainers to decide what to do

test_class = get_class_name(package, src, package_prefixes)

test_name = define_test(
Expand Down