Skip to content

Commit

Permalink
[rb] Use Bazel JDK when starting server
Browse files Browse the repository at this point in the history
This ensures the server is not started with a system JDK which might be
missing, outdated or simply inaccessible due to Bazel test sandboxing.
  • Loading branch information
p0deje committed Apr 3, 2024
1 parent ef3d9e8 commit 66adbbb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rb/lib/selenium/server.rb
Expand Up @@ -241,7 +241,7 @@ def process
# extract any additional_args that start with -D as options
properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^-D/] }
args = ['-jar', @jar, @role, '--port', @port.to_s]
server_command = ['java'] + properties + args + @additional_args
server_command = [java_bin] + properties + args + @additional_args
cp = WebDriver::ChildProcess.build(*server_command)

if @log.is_a?(String)
Expand All @@ -256,6 +256,14 @@ def process
end
end

def java_bin
if ENV.key?('BAZEL_TEST') && ENV.key?('JAVA_HOME')
"#{ENV['JAVA_HOME']}/bin/java"
else
'java'
end
end

def poll_for_service
return if socket.connected?

Expand Down

0 comments on commit 66adbbb

Please sign in to comment.