Skip to content

Commit

Permalink
[bazel] Make generated test library name more unique
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Nov 24, 2018
1 parent e615772 commit b711b72
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
7 changes: 5 additions & 2 deletions java/bazel-rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ def _impl(ctx):
)

def gen_java_tests(size, srcs = [], tags = [], deps = [], **kwargs):
key = size + str(srcs) + str(tags) + str(deps) + native.package_name()
lib_name = "%s" % hash(key)

native.java_library(
name = "%s-lib" % native.package_name(),
name = lib_name,
srcs = srcs,
deps = deps,
)

deps.append(":%s-lib" % native.package_name())
deps.append(":%s" % lib_name)

actual_tags = []
actual_tags.extend(tags)
Expand Down
24 changes: 12 additions & 12 deletions java/client/test/org/openqa/selenium/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ SMALL_TESTS = [
# "ProxyTest.java", # needs more dependencies
]

#gen_java_tests(
# size = "small",
# srcs = SMALL_TESTS,
# deps = [
# "//java/client/src/org/openqa/selenium",
# "//third_party/java/assertj",
# "//third_party/java/guava",
# "//third_party/java/junit",
# "//third_party/java/mockito:mockito-core",
# ],
#)
gen_java_tests(
size = "small",
srcs = SMALL_TESTS,
deps = [
"//java/client/src/org/openqa/selenium",
"//third_party/java/assertj",
"//third_party/java/guava",
"//third_party/java/junit",
"//third_party/java/mockito:mockito-core",
],
)

java_library(
name = "selenium",
Expand Down Expand Up @@ -68,7 +68,7 @@ gen_java_tests(
"//third_party/java/jetty",
"//third_party/java/junit",
"//third_party/java/littleshoot",
"//third_party/java/mockito",
"//third_party/java/mockito:mockito-core",
"//third_party/java/netty",
"//third_party/java/servlet:javax.servlet-api",
],
Expand Down
2 changes: 1 addition & 1 deletion java/client/test/org/openqa/selenium/remote/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ gen_java_tests(
"//third_party/java/assertj",
"//third_party/java/guava",
"//third_party/java/junit",
"//third_party/java/mockito",
"//third_party/java/mockito:mockito-core",
],
)
2 changes: 1 addition & 1 deletion third_party/java/mockito/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
java_import(
name = "mockito",
name = "mockito-core",
jars = ["mockito-core-2.18.0.jar"],
licenses = [
"notice", # MIT
Expand Down

0 comments on commit b711b72

Please sign in to comment.