Skip to content

Commit

Permalink
[bazel]: Update remote common tests to use generated tests
Browse files Browse the repository at this point in the history
Which uncovered a bug in how we generated the test
class names (now fixed!). To run all the tests of
a given size, do something like:

```
bazel test --test_size_filters=small java/...:all
```
  • Loading branch information
shs96c committed Nov 19, 2018
1 parent 005395d commit d76cba8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
8 changes: 4 additions & 4 deletions java/bazel-rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ def _shortName(file):
# We assume that package name matches directory structure, which may not
# actually be true, but is for Selenium.
def _className(file):
dir = native.package_name()
name = file.rpartition(".")[0]
className = native.package_name() + "/" + name

segments = dir.split('/')
segments = className.split('/')
idx = len(segments) - 1
for i, segment in enumerate(segments):
if _contains(_PREFIXES, segment):
idx = i
break
return ".".join(segments[idx:]) + "." + _shortName(file)
return ".".join(segments[idx:])

def _impl(ctx):
for src in ctx.files.srcs:
Expand All @@ -31,7 +32,6 @@ def _impl(ctx):
srcs = ctx.attr.srcs,
size = ctx.attr.size,
deps = ctx.attr.deps)
print(test)

def gen_java_tests(name, srcs=[], deps=[], **kwargs):
native.java_library(
Expand Down
39 changes: 22 additions & 17 deletions java/client/test/org/openqa/selenium/remote/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
java_test(name = 'common-tests',
test_class = 'org.openqa.selenium.remote.RemoteCommonTests',
srcs = [
'DesiredCapabilitiesTest.java',
'RemoteCommonTests.java',
'http/JsonHttpCommandCodecTest.java',
'http/JsonHttpResponseCodecTest.java',
'http/W3CHttpResponseCodecTest.java',
],
deps = [
'//java/client/src/org/openqa/selenium:selenium',
'//java/client/src/org/openqa/selenium/remote:remote',
'//java/client/src/org/openqa/selenium/remote:types',
'//third_party/java/guava:guava',
'//third_party/java/assertj:assertj',
'//third_party/java/junit:junit',
])
load("//java:bazel-rules.bzl", "gen_java_tests")

SMALL_TESTS = [
"DesiredCapabilitiesTest.java",
"RemoteCommonTests.java",
"http/JsonHttpCommandCodecTest.java",
"http/JsonHttpResponseCodecTest.java",
"http/W3CHttpResponseCodecTest.java",
]

gen_java_tests(
name = "common-tests",
srcs = SMALL_TESTS,
size = "small",
deps = [
"//java/client/src/org/openqa/selenium:selenium",
"//java/client/src/org/openqa/selenium/remote:remote",
"//third_party/java/assertj:assertj",
"//third_party/java/guava:guava",
"//third_party/java/junit:junit",
],
)

0 comments on commit d76cba8

Please sign in to comment.