Skip to content

Commit 16bc793

Browse files
committed
[build] remove more ruby test targets that do not apply and support remote-bidi targets for each test
1 parent b3b23f5 commit 16bc793

File tree

3 files changed

+55
-13
lines changed

3 files changed

+55
-13
lines changed

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ bazel test //py:all
397397
Test targets:
398398

399399
| Command | Description |
400-
| -------------------------------------------------------------------------------- | -------------------------------------------------- |
400+
|----------------------------------------------------------------------------------|----------------------------------------------------|
401401
| `bazel test //rb/...` | Run unit, all integration tests and lint |
402402
| `bazel test //rb:lint` | Run RuboCop linter |
403403
| `bazel test //rb/spec/...` | Run unit and integration tests for all browsers |
@@ -406,23 +406,29 @@ Test targets:
406406
| `bazel test //rb/spec/... --test_size_filters large` | Run integration tests for all browsers |
407407
| `bazel test //rb/spec/integration/...` | Run integration tests for all browsers |
408408
| `bazel test //rb/spec/integration/... --test_tag_filters firefox` | Run integration tests for local Firefox only |
409-
| `bazel test //rb/spec/integration/... --test_tag_filters firefox-remote` | Run integration tests for remote Firefox only |
409+
| `bazel test //rb/spec/integration/... --test_tag_filters bidi` | Run integration tests for all bidi tests |
410410
| `bazel test //rb/spec/integration/... --test_tag_filters firefox,firefox-remote` | Run integration tests for local and remote Firefox |
411411

412412
Ruby test targets have the same name as the spec file with `_spec.rb` removed, so you can run them individually.
413-
Integration tests targets also have a browser and remote suffix to control which browser to pick and whether to use Grid.
414-
415-
| Test file | Test target |
416-
| ------------------------------------------------------- | ---------------------------------------------------------------- |
417-
| `rb/spec/unit/selenium/webdriver/proxy_spec.rb` | `//rb/spec/unit/selenium/webdriver:proxy` |
418-
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome` |
419-
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome-remote` |
420-
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-firefox` |
421-
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-firefox-remote` |
413+
Integration tests targets also allow specific suffixes to control specific browsers and settings.
414+
These targets are dynamically generated in the `rb/spec/tests.bzl` file
415+
Running in BiDi mode will be increasingly important as we re-implement classic selenium functionality with BiDi protocol.
416+
Not every test is set to run with BiDi by default, and which spec files are valid is explicitly
417+
with the `BIDI_BROWSERS` in the `tests.bzl` file and `_BIDI_FILES` in `//rb/spec/integration/selenium/webdriver/BUILD.bazel`
418+
419+
| Test file | Test target |
420+
| ------------------------------------------------------- |----------------------------------------------------------------------|
421+
| `rb/spec/unit/selenium/webdriver/proxy_spec.rb` | `//rb/spec/unit/selenium/webdriver:proxy` |
422+
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome` |
423+
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-firefox-beta` |
424+
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome-remote` |
425+
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-firefox-bidi` |
426+
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome-remote-bidi` |
422427

423428
Supported browsers:
424429

425430
* `chrome`
431+
* `chrome-beta`
426432
* `edge`
427433
* `firefox`
428434
* `firefox-beta`
@@ -441,6 +447,7 @@ Supported environment variables for use with `--test_env`:
441447
- `WD_REMOTE_URL` - URL of an already running server to use for remote tests
442448
- `DOWNLOAD_SERVER` - when `WD_REMOTE_URL` not set; whether to download and use most recently released server version for remote tests
443449
- `DEBUG` - turns on verbose debugging
450+
- `WEBDRIVER_BIDI` - enables `web_socket_url` in the capabilities
444451
- `HEADLESS` - for chrome, edge and firefox; runs tests in headless mode
445452
- `DISABLE_BUILD_CHECK` - for chrome and edge; whether to ignore driver and browser version mismatches (allows testing Canary builds)
446453
- `CHROME_BINARY` - path to test specific Chrome browser

rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
load("//rb/spec:tests.bzl", "rb_integration_test")
1+
load("//rb/spec:tests.bzl", "BIDI_BROWSERS", "rb_integration_test")
22

33
[
44
rb_integration_test(
55
name = file[:-8],
66
srcs = [file],
7+
browsers = BIDI_BROWSERS,
78
tags = [
89
"bidi",
910
"exclusive-if-local",

rb/spec/tests.bzl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ load(
99
"firefox_data",
1010
)
1111

12+
BIDI_BROWSERS = [
13+
"chrome",
14+
"chrome-beta",
15+
"edge",
16+
"firefox",
17+
"firefox-beta",
18+
]
19+
1220
BROWSERS = {
1321
"chrome": {
1422
"data": chrome_data,
@@ -215,7 +223,7 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
215223
)
216224

217225
# Generate a test target for bidi browser execution if there is a matching tag
218-
if "bidi" in tags:
226+
if "bidi" in tags and browser in BIDI_BROWSERS:
219227
rb_test(
220228
name = "{}-{}-bidi".format(name, browser),
221229
size = "large",
@@ -233,6 +241,32 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
233241
visibility = ["//rb:__subpackages__"],
234242
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
235243
)
244+
rb_test(
245+
name = "{}-{}-remote-bidi".format(name, browser),
246+
size = "large",
247+
srcs = srcs,
248+
args = ["rb/spec/"],
249+
data = BROWSERS[browser]["data"] + data + [
250+
"//common/src/web",
251+
"//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar",
252+
"//rb/spec:java-location",
253+
"@bazel_tools//tools/jdk:current_java_runtime",
254+
],
255+
env = BROWSERS[browser]["env"] | {
256+
"WD_BAZEL_JAVA_LOCATION": "$(rootpath //rb/spec:java-location)",
257+
"WD_SPEC_DRIVER": "remote",
258+
"WEBDRIVER_BIDI": "true",
259+
},
260+
main = "@bundle//bin:rspec",
261+
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + ["{}-remote-bidi".format(browser)],
262+
deps = depset(
263+
["//rb/spec/integration/selenium/webdriver:spec_helper", "//rb/lib/selenium/webdriver:bidi"] +
264+
BROWSERS[browser]["deps"] +
265+
deps,
266+
),
267+
visibility = ["//rb:__subpackages__"],
268+
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
269+
)
236270

237271
def rb_unit_test(name, srcs, deps, data = []):
238272
rb_test(

0 commit comments

Comments
 (0)