Skip to content

Commit b456e60

Browse files
committed
[rb] Use Bazel JDK in remote tests
1 parent 8688ad2 commit b456e60

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

rb/lib/selenium/server.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def download_server(uri, destination)
183183
def initialize(jar, opts = {})
184184
raise Errno::ENOENT, jar unless File.exist?(jar)
185185

186+
@java = opts.fetch(:java, 'java')
186187
@jar = jar
187188
@host = '127.0.0.1'
188189
@role = opts.fetch(:role, 'standalone')
@@ -241,7 +242,7 @@ def process
241242
# extract any additional_args that start with -D as options
242243
properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^-D/] }
243244
args = ['-jar', @jar, @role, '--port', @port.to_s]
244-
server_command = ['java'] + properties + args + @additional_args
245+
server_command = [@java] + properties + args + @additional_args
245246
cp = WebDriver::ChildProcess.build(*server_command)
246247

247248
if @log.is_a?(String)

rb/spec/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,13 @@ rb_library(
117117
"//rb/spec/unit/selenium/webdriver/support:select",
118118
],
119119
)
120+
121+
genrule(
122+
name = "java-location",
123+
srcs = [],
124+
outs = ["java-location.txt"],
125+
cmd = "echo $(JAVA) > $@",
126+
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
127+
visibility = ["//rb/spec:__subpackages__"],
128+
)
129+
.

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def app_server
8787
def remote_server
8888
@remote_server ||= Selenium::Server.new(
8989
remote_server_jar,
90+
java: bazel_java,
9091
port: random_port,
9192
log_level: WebDriver.logger.debug? && 'FINE',
9293
background: true,
@@ -95,6 +96,12 @@ def remote_server
9596
)
9697
end
9798

99+
def bazel_java
100+
return unless ENV.key?('WD_BAZEL_JAVA_LOCATION')
101+
102+
File.expand_path(File.read(File.expand_path(ENV.fetch('WD_BAZEL_JAVA_LOCATION'))).chomp)
103+
end
104+
98105
def reset_remote_server
99106
@remote_server&.stop
100107
@remote_server = nil

rb/spec/tests.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,13 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
174174
data = BROWSERS[browser]["data"] + data + [
175175
"//common/src/web",
176176
"//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar",
177+
"//rb/spec:java-location",
178+
"@bazel_tools//tools/jdk:current_java_runtime",
177179
],
178-
env = BROWSERS[browser]["env"] | {"WD_SPEC_DRIVER": "remote"},
180+
env = BROWSERS[browser]["env"] | {
181+
"WD_BAZEL_JAVA_LOCATION": "$(rootpath //rb/spec:java-location)",
182+
"WD_SPEC_DRIVER": "remote",
183+
},
179184
main = "@bundle//bin:rspec",
180185
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + [
181186
"{}-remote".format(browser),

0 commit comments

Comments
 (0)