Skip to content

Commit

Permalink
[bazel] Avoid test names clashing if declared repeatedly
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jul 9, 2019
1 parent b28fab0 commit dc6dbc1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions java/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def java_test_suite(
name,
srcs,
resources=None,
jvm_flags=[],
deps=None,
visibility=None,
size = None,
Expand Down Expand Up @@ -89,14 +90,20 @@ def java_test_suite(
for src in srcs:
if src.endswith('Test.java'):
test_name = src[:-len('.java')]

tests += [test_name]
test_class = None
if pkg != None:
test_class = pkg + "." + test_name.replace("/", ".")

if test_name in native.existing_rules():
test_name = "%s-%s" % (name, test_name)

native.java_test(
name = test_name,
srcs = [src],
size = size,
jvm_flags = jvm_flags,
test_class = test_class,
resources = resources,
tags = actual_tags,
Expand Down

0 comments on commit dc6dbc1

Please sign in to comment.