Skip to content

Commit

Permalink
[java] More progress building with bazel
Browse files Browse the repository at this point in the history
All of java/client/src should build with bazel.
The java/client/test tree is a work in progress.

Running tests is the current bottleneck as anything that tries
to start a browser crashes due to the bazel sandbox:

My latest results for `bazel test java/client/test/...`:

//java/client/test/org/openqa/selenium/atoms:CompiledAtomsNotLeakingTest (cached) PASSED in 0.3s
//java/client/test/org/openqa/selenium/atoms:InputAtomsTest     (cached) PASSED in 0.4s
//java/client/test/org/openqa/selenium/io:CircularOutputStreamTest (cached) PASSED in 0.7s
//java/client/test/org/openqa/selenium/io:FileHandlerTest       (cached) PASSED in 0.7s
//java/client/test/org/openqa/selenium/io:TemporaryFilesystemTest (cached) PASSED in 0.7s
//java/client/test/org/openqa/selenium/io:ZipTest               (cached) PASSED in 0.7s
//java/client/test/org/openqa/selenium/net:LinuxEphemeralPortRangeDetectorTest (cached) PASSED in 0.4s
//java/client/test/org/openqa/selenium/net:NetworkUtilsTest     (cached) PASSED in 0.4s
//java/client/test/org/openqa/selenium/net:UrlCheckerTest       (cached) PASSED in 1.1s
//java/client/test/org/openqa/selenium/os:CommandLineTest       (cached) PASSED in 3.0s
//java/client/test/org/openqa/selenium/support:small-tests      (cached) PASSED in 2.5s
//java/client/test/org/openqa/selenium/testing:IgnoreComparatorUnitTest (cached) PASSED in 0.7s
//java/client/test/org/openqa/selenium/support:large-tests               FAILED in 12.2s
  • Loading branch information
jleyba committed May 6, 2019
1 parent 4a49681 commit ae11ca9
Show file tree
Hide file tree
Showing 40 changed files with 914 additions and 81 deletions.
Empty file added BUILD.bazel
Empty file.
11 changes: 11 additions & 0 deletions copy_file.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def copy_file(name, src, out = None, **kwargs):
if out == None:
out = src

native.genrule(
name = name,
srcs = [src],
outs = [out],
cmd = "cp $< $@",
**kwargs
)
21 changes: 21 additions & 0 deletions cpp/prebuilt/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("//:copy_file.bzl", "copy_file")

copy_file(
name = "noblur32",
out = "i386/x_ignore_nofocus.so",
src = "i386/libnoblur.so",
visibility = [
"//dotnet/src/webdriver:__pkg__",
"//java/client/src/org/openqa/selenium/firefox/xpi:__pkg__",
],
)

copy_file(
name = "noblur64",
out = "amd64/x_ignore_nofocus.so",
src = "amd64/libnoblur64.so",
visibility = [
"//dotnet/src/webdriver:__pkg__",
"//java/client/src/org/openqa/selenium/firefox/xpi:__pkg__",
],
)
58 changes: 58 additions & 0 deletions java/client/src/com/thoughtworks/selenium/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
java_library(
name = "api",
srcs = [
"CommandProcessor.java",
"Selenium.java",
"SeleniumException.java",
"Wait.java",
],
visibility = [
"//java/client/src/com/thoughtworks/selenium/condition:__pkg__",
],
)

java_library(
name = "selenium",
srcs = [
"BrowserConfigurationOptions.java",
"DefaultRemoteCommand.java",
"DefaultSelenium.java",
"HttpCommandProcessor.java",
"RemoteCommand.java",
"ScreenshotListener.java",
"SeleneseTestBase.java",
"SeleneseTestCase.java",
"SeleneseTestNgHelper.java",
"SeleniumLogLevels.java",
],
visibility = [
"//java/client/src/com/thoughtworks/selenium:__subpackages__",
"//java/client/test/com/thoughtworks/selenium:__subpackages__",
"//java/server/src/com/thoughtworks/selenium:__pkg__",
],
exports = [
":api",
],
deps = [
":api",
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/edge",
"//java/client/src/org/openqa/selenium/net",
"//third_party/java/guava",
"//third_party/java/junit",
"//third_party/java/testng",
],
)

java_library(
name = "leg-rc",
visibility = [
"//visibility:public",
],
exports = [
":api",
":selenium",
"//java/client/src/com/thoughtworks/selenium/condition",
"//java/client/src/com/thoughtworks/selenium/webdriven",
],
)
11 changes: 11 additions & 0 deletions java/client/src/com/thoughtworks/selenium/condition/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
java_library(
name = "condition",
srcs = glob(["*.java"]),
visibility = [
"//java/client/src/com/thoughtworks/selenium:__pkg__",
],
deps = [
"//java/client/src/com/thoughtworks/selenium:api",
"//third_party/java/junit",
],
)
105 changes: 104 additions & 1 deletion java/client/src/com/thoughtworks/selenium/webdriven/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1 +1,104 @@
exports_files(["htmlutils.js", "injectableSelenium.js"])
load("//:copy_file.bzl", "copy_file")

exports_files([
"htmlutils.js",
"injectableSelenium.js",
])

java_library(
name = "webdriven",
srcs = [
"CompoundMutator.java",
"ExplodingSupplier.java",
"FunctionDeclaration.java",
"SeleniumMutator.java",
"VariableDeclaration.java",
"WebDriverBackedSelenium.java",
"WebDriverCommandProcessor.java",
],
resources = [
"htmlutils.js",
"injectableSelenium.js",
":findElement",
":findOption",
":fireEvent",
":fireEventAt",
":getAttribute",
":getText",
":linkLocator",
":isElementPresent",
":isSomethingSelected",
":isTextPresent",
":isVisible",
":setCursorPosition",
":type",
# TODO(simons): remove sizzle. There are no longer any browsers that need it.
":sizzle",
],
visibility = [
"//java/client/src/com/thoughtworks/selenium:__subpackages__",
"//java/client/test/com/thoughtworks/selenium:__subpackages__",
"//java/server/src/com/thoughtworks/selenium/webdriven:__pkg__",
"//java/server/src/org/openqa/grid/selenium:__pkg__",
"//java/server/src/org/openqa/selenium/server/htmlrunner:__pkg__",
],
exports = [
":emulation-api",
"//java/client/src/com/thoughtworks/selenium/webdriven/commands",
],
deps = [
":emulation-api",
"//java/client/src/com/thoughtworks/selenium",
"//java/client/src/com/thoughtworks/selenium/webdriven/commands",
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/remote",
"//third_party/java/guava",
],
)

java_library(
name = "emulation-api",
srcs = [
"ElementFinder.java",
"JavascriptLibrary.java",
"ScriptMutator.java",
"SeleneseCommand.java",
"Timer.java",
"Windows.java",
],
visibility = [
"//java/client/src/com/thoughtworks/selenium:__subpackages__",
"//java/client/test/com/thoughtworks/selenium:__subpackages__",
],
deps = [
"//java/client/src/com/thoughtworks/selenium",
"//java/client/src/org/openqa/selenium:core",
"//third_party/java/guava",
],
)

[copy_file(
name = name,
src = "//javascript/selenium-atoms:%s.js" % name,
out = "%s.js" % name,
) for name in [
"findElement",
"findOption",
"fireEvent",
"fireEventAt",
"getAttribute",
"getText",
"linkLocator",
"isElementPresent",
"isSomethingSelected",
"isTextPresent",
"isVisible",
"setCursorPosition",
"type",
]]

copy_file(
name = "sizzle",
src = "//third_party/js/sizzle",
out = "sizzle.js",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
java_library(
name = "commands",
srcs = glob(["*.java"]),
visibility = [
"//java/client/src/com/thoughtworks/selenium/webdriven:__pkg__",
],
deps = [
"//java/client/src/com/thoughtworks/selenium",
"//java/client/src/com/thoughtworks/selenium/webdriven:emulation-api",
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/io",
"//third_party/java/guava",
],
)
14 changes: 14 additions & 0 deletions java/client/src/org/openqa/selenium/chrome/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
java_library(
name = "chrome",
srcs = glob(["*.java"]),
visibility = ["//visibility:public"],
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/devtools",
"//java/client/src/org/openqa/selenium/json",
"//java/client/src/org/openqa/selenium/remote",
"//java/client/src/org/openqa/selenium/remote/http",
"//third_party/java/guava",
"//third_party/java/service",
],
)
1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/devtools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ java_library(
name = "devtools",
srcs = glob(["*.java"]),
visibility = [
"//java/client/src/org/openqa/selenium/chrome:__pkg__",
"//java/client/src/org/openqa/selenium/remote:__pkg__",
],
deps = [
Expand Down
11 changes: 11 additions & 0 deletions java/client/src/org/openqa/selenium/edge/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
java_library(
name = "edge",
srcs = glob(["*.java"]),
visibility = ["//visibility:public"],
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/remote",
"//third_party/java/guava",
"//third_party/java/service",
],
)
25 changes: 25 additions & 0 deletions java/client/src/org/openqa/selenium/firefox/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("//:copy_file.bzl", "copy_file")

java_library(
name = "firefox",
srcs = glob(["*.java"]),
resources = [":prefs"],
visibility = ["//visibility:public"],
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/io",
"//java/client/src/org/openqa/selenium/json",
"//java/client/src/org/openqa/selenium/net",
"//java/client/src/org/openqa/selenium/os",
"//java/client/src/org/openqa/selenium/remote",
"//java/client/src/org/openqa/selenium/remote/http",
"//third_party/java/guava",
"//third_party/java/service",
],
)

copy_file(
name = "prefs",
src = "//third_party/js/selenium:webdriver.json",
out = "webdriver_prefs.json",
)
40 changes: 40 additions & 0 deletions java/client/src/org/openqa/selenium/firefox/xpi/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
load("//:copy_file.bzl", "copy_file")

java_library(
name = "xpi",
srcs = glob(["*.java"]),
resources = [
":amd64",
":i386",
":webdriver_xpi",
],
visibility = ["//visibility:public"],
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/firefox",
"//java/client/src/org/openqa/selenium/io",
"//java/client/src/org/openqa/selenium/net",
"//java/client/src/org/openqa/selenium/os",
"//java/client/src/org/openqa/selenium/remote",
"//third_party/java/guava",
"//third_party/java/service",
],
)

copy_file(
name = "webdriver_xpi",
src = "//third_party/js/selenium:webdriver_xpi",
out = "webdriver.xpi",
)

copy_file(
name = "i386",
src = "//cpp/prebuilt:noblur32",
out = "x86/x_ignore_nofocus.so",
)

copy_file(
name = "amd64",
src = "//cpp/prebuilt:noblur64",
out = "amd64/x_ignore_nofocus.so",
)
11 changes: 11 additions & 0 deletions java/client/src/org/openqa/selenium/ie/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
java_library(
name = "ie",
srcs = glob(["*.java"]),
visibility = ["//visibility:public"],
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/remote",
"//third_party/java/guava",
"//third_party/java/service",
],
)
4 changes: 4 additions & 0 deletions java/client/src/org/openqa/selenium/io/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ java_library(
name = "io",
srcs = glob(["*.java"]),
visibility = [
"//java/client/src/com/thoughtworks/selenium/webdriven/commands:__pkg__",
"//java/client/src/org/openqa/selenium/firefox:__pkg__",
"//java/client/src/org/openqa/selenium/firefox/xpi:__pkg__",
"//java/client/src/org/openqa/selenium/os:__pkg__",
"//java/client/src/org/openqa/selenium/remote:__pkg__",
"//java/client/test/org/openqa/selenium/environment:__pkg__",
"//java/client/test/org/openqa/selenium/firefox:__pkg__",
"//java/client/test/org/openqa/selenium/io:__pkg__",
],
deps = [
Expand Down
6 changes: 6 additions & 0 deletions java/client/src/org/openqa/selenium/net/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ java_library(
name = "net",
srcs = glob(["*.java"]),
visibility = [
"//java/client/src/com/thoughtworks/selenium:__pkg__",
"//java/client/src/org/openqa/selenium/firefox:__pkg__",
"//java/client/src/org/openqa/selenium/firefox/xpi:__pkg__",
"//java/client/src/org/openqa/selenium/remote:__pkg__",
"//java/client/src/org/openqa/selenium/safari:__pkg__",
"//java/client/test/org/openqa/selenium:__pkg__",
"//java/client/test/org/openqa/selenium/environment:__pkg__",
"//java/client/test/org/openqa/selenium/net:__pkg__",
"//java/client/test/org/openqa/selenium/testing/drivers:__pkg__",
],
deps = [
"//java/client/src/org/openqa/selenium:core",
Expand Down
11 changes: 11 additions & 0 deletions java/client/src/org/openqa/selenium/opera/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
java_library(
name = "opera",
srcs = glob(["*.java"]),
visibility = ["//visibility:public"],
deps = [
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/remote",
"//third_party/java/guava",
"//third_party/java/service",
],
)
2 changes: 2 additions & 0 deletions java/client/src/org/openqa/selenium/os/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ java_library(
srcs = glob(["*.java"]),
visibility = [
"//java/client/src/org/openqa/selenium:__pkg__",
"//java/client/src/org/openqa/selenium/firefox:__pkg__",
"//java/client/src/org/openqa/selenium/firefox/xpi:__pkg__",
"//java/client/src/org/openqa/selenium/remote:__pkg__",
"//java/client/test/org/openqa/selenium:__subpackages__",
"//java/client/test/org/openqa/selenium/build:__pkg__",
Expand Down
1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/remote/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ java_library(
exports = [
":api",
":capabilities",
":remote-lib",
],
deps = [
":api",
Expand Down
Loading

0 comments on commit ae11ca9

Please sign in to comment.