Skip to content

Commit

Permalink
[java] Remote selenium-remote tag from test targets
Browse files Browse the repository at this point in the history
If it's there, then `bazel query "attr(tags, 'remote', tests(//java/...))`
would also return non-remote targets. This happens because Bazel queries
for partial match in attribute ("selenium-remote" contains "remote").
  • Loading branch information
p0deje committed May 2, 2023
1 parent c2944a1 commit 18164af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ jobs:
bazel query "attr(tags, ${{ matrix.browser }}, tests(//java/...)) except attr(tags, 'rc|remote', tests(//java/...))" |
xargs bazel test --flaky_test_attempts 3
server-tests:
name: Server Tests
remote-tests:
name: Remote Tests
needs: small-tests
uses: ./.github/workflows/bazel.yml
strategy:
Expand All @@ -91,10 +91,10 @@ jobs:
- browser: firefox
browser-version: latest-devedition
with:
name: Server Tests (${{ matrix.browser }}, ${{ matrix.browser-version }})
name: Remote Tests (${{ matrix.browser }}, ${{ matrix.browser-version }})
browser: ${{ matrix.browser }}
browser-version: ${{ matrix.browser-version }}
cache-key: java-${{ matrix.browser }}-server-tests
cache-key: java-${{ matrix.browser }}-remote-tests
run: >
bazel query "attr(tags, ${{ matrix.browser }}, tests(//java/...)) intersect attr(tags, 'remote', tests(//java/...))" |
xargs bazel test --flaky_test_attempts 3
9 changes: 7 additions & 2 deletions java/private/selenium_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def selenium_test(name, test_class, size = "medium", browsers = BROWSERS.keys(),
jvm_flags = kwargs["jvm_flags"] if "jvm_flags" in kwargs else []
tags = kwargs["tags"] if "tags" in kwargs else []

remote = False
if "selenium-remote" in tags:
tags.remove("selenium-remote")
remote = True

stripped_args = dict(**kwargs)
stripped_args.pop("data", None)
stripped_args.pop("jvm_flags", None)
Expand Down Expand Up @@ -98,7 +103,7 @@ def selenium_test(name, test_class, size = "medium", browsers = BROWSERS.keys(),
)
all_tests.append(":%s" % test)

if "selenium-remote" in tags:
if remote:
java_junit5_test(
name = "%s-remote" % test,
test_class = test_class,
Expand All @@ -108,7 +113,7 @@ def selenium_test(name, test_class, size = "medium", browsers = BROWSERS.keys(),
"-Dselenium.browser.remote.path=$(location @selenium//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar)",
],
# No need to lint remote tests as the code for non-remote is the same and they get linted
tags = BROWSERS[browser]["tags"] + tags + ["remote", "no-lint"],
tags = BROWSERS[browser]["tags"] + tags + ["remote1", "no-lint"],
data = BROWSERS[browser]["data"] + data + [
"@selenium//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar",
],
Expand Down

0 comments on commit 18164af

Please sign in to comment.