Skip to content

Commit f98e870

Browse files
authored
[rb] Run unit tests as a single Bazel target instead of per-file (#17616)
1 parent 1a85379 commit f98e870

22 files changed

Lines changed: 58 additions & 402 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,14 @@ Test targets:
448448
| `bazel test //rb/spec/integration/... --test_tag_filters firefox-remote` | Run integration tests for remote Firefox only |
449449
| `bazel test //rb/spec/integration/... --test_tag_filters bidi` | Run bidi-mode tests across every browser that supports BiDi |
450450

451-
Ruby test targets have the same name as the spec file with `_spec.rb` removed, so you can run them individually.
452-
Integration test targets also have a browser-variant suffix to control which browser to pick and whether to use Grid or BiDi
453-
(e.g. `-chrome`, `-chrome-remote`, `-chrome-beta-bidi`).
451+
All unit specs run as a single target, `//rb/spec/unit:unit`.
452+
453+
Integration test targets have the same name as the spec file with `_spec.rb` removed, plus a
454+
browser-variant suffix to control which browser to pick and whether to use Grid or BiDi
455+
(e.g. `-chrome`, `-chrome-remote`, `-chrome-beta-bidi`), so you can run them individually.
454456

455457
| Test file | Test target |
456458
| ------------------------------------------------------- | ---------------------------------------------------------------- |
457-
| `rb/spec/unit/selenium/webdriver/proxy_spec.rb` | `//rb/spec/unit/selenium/webdriver:proxy` |
458459
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome` |
459460
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-chrome-remote` |
460461
| `rb/spec/integration/selenium/webdriver/driver_spec.rb` | `//rb/spec/integration/selenium/webdriver:driver-firefox` |

rb/spec/BUILD.bazel

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -48,67 +48,8 @@ rb_library(
4848
"//rb/spec/integration/selenium/webdriver/remote:driver",
4949
"//rb/spec/integration/selenium/webdriver/remote:element",
5050
"//rb/spec/integration/selenium/webdriver/safari:driver",
51-
"//rb/spec/unit/selenium:devtools",
52-
"//rb/spec/unit/selenium:server",
53-
"//rb/spec/unit/selenium/devtools:cdp_client_generator",
54-
"//rb/spec/unit/selenium/webdriver:file_reaper",
55-
"//rb/spec/unit/selenium/webdriver:guard",
56-
"//rb/spec/unit/selenium/webdriver:proxy",
57-
"//rb/spec/unit/selenium/webdriver:search_context",
58-
"//rb/spec/unit/selenium/webdriver:socket_poller",
59-
"//rb/spec/unit/selenium/webdriver:spec_helper",
60-
"//rb/spec/unit/selenium/webdriver:wait",
61-
"//rb/spec/unit/selenium/webdriver/chrome:driver",
62-
"//rb/spec/unit/selenium/webdriver/chrome:options",
63-
"//rb/spec/unit/selenium/webdriver/chrome:service",
64-
"//rb/spec/unit/selenium/webdriver/common:action_builder",
65-
"//rb/spec/unit/selenium/webdriver/common:credentials",
66-
"//rb/spec/unit/selenium/webdriver/common:driver_finder",
67-
"//rb/spec/unit/selenium/webdriver/common:logger",
68-
"//rb/spec/unit/selenium/webdriver/common:selenium_manager",
69-
"//rb/spec/unit/selenium/webdriver/common:service",
70-
"//rb/spec/unit/selenium/webdriver/common:virtual_authenticator_options",
71-
"//rb/spec/unit/selenium/webdriver/common/interactions",
72-
"//rb/spec/unit/selenium/webdriver/common/interactions:input_device",
73-
"//rb/spec/unit/selenium/webdriver/common/interactions:interaction",
74-
"//rb/spec/unit/selenium/webdriver/common/interactions:key_actions",
75-
"//rb/spec/unit/selenium/webdriver/common/interactions:key_input",
76-
"//rb/spec/unit/selenium/webdriver/common/interactions:none_input",
77-
"//rb/spec/unit/selenium/webdriver/common/interactions:pause",
78-
"//rb/spec/unit/selenium/webdriver/common/interactions:pointer_actions",
79-
"//rb/spec/unit/selenium/webdriver/common/interactions:pointer_cancel",
80-
"//rb/spec/unit/selenium/webdriver/common/interactions:pointer_event_prop",
81-
"//rb/spec/unit/selenium/webdriver/common/interactions:pointer_input",
82-
"//rb/spec/unit/selenium/webdriver/common/interactions:pointer_move",
83-
"//rb/spec/unit/selenium/webdriver/common/interactions:pointer_press",
84-
"//rb/spec/unit/selenium/webdriver/common/interactions:scroll",
85-
"//rb/spec/unit/selenium/webdriver/common/interactions:typing_interactions",
86-
"//rb/spec/unit/selenium/webdriver/common/interactions:wheel_actions",
87-
"//rb/spec/unit/selenium/webdriver/common/interactions:wheel_input",
88-
"//rb/spec/unit/selenium/webdriver/devtools:request",
89-
"//rb/spec/unit/selenium/webdriver/devtools:response",
90-
"//rb/spec/unit/selenium/webdriver/edge:driver",
91-
"//rb/spec/unit/selenium/webdriver/edge:options",
92-
"//rb/spec/unit/selenium/webdriver/edge:service",
93-
"//rb/spec/unit/selenium/webdriver/firefox:driver",
94-
"//rb/spec/unit/selenium/webdriver/firefox:extension",
95-
"//rb/spec/unit/selenium/webdriver/firefox:options",
96-
"//rb/spec/unit/selenium/webdriver/firefox:profile",
97-
"//rb/spec/unit/selenium/webdriver/firefox:service",
98-
"//rb/spec/unit/selenium/webdriver/ie:driver",
99-
"//rb/spec/unit/selenium/webdriver/ie:options",
100-
"//rb/spec/unit/selenium/webdriver/ie:service",
101-
"//rb/spec/unit/selenium/webdriver/remote:bridge",
102-
"//rb/spec/unit/selenium/webdriver/remote:capabilities",
103-
"//rb/spec/unit/selenium/webdriver/remote:driver",
104-
"//rb/spec/unit/selenium/webdriver/remote/http:common",
105-
"//rb/spec/unit/selenium/webdriver/remote/http:default",
106-
"//rb/spec/unit/selenium/webdriver/safari:driver",
107-
"//rb/spec/unit/selenium/webdriver/safari:options",
108-
"//rb/spec/unit/selenium/webdriver/safari:service",
109-
"//rb/spec/unit/selenium/webdriver/support:color",
110-
"//rb/spec/unit/selenium/webdriver/support:event_firing",
111-
"//rb/spec/unit/selenium/webdriver/support:select",
51+
"//rb/spec/unit",
52+
"//rb/spec/unit:spec_helper",
11253
],
11354
)
11455

rb/spec/tests.bzl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,3 @@ def rb_integration_test(
266266
visibility = ["//rb:__subpackages__"],
267267
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
268268
)
269-
270-
def rb_unit_test(name, srcs, deps, data = [], flaky = False):
271-
rb_test(
272-
name = name,
273-
size = "small",
274-
srcs = srcs,
275-
args = ["rb/spec/"],
276-
flaky = flaky,
277-
main = "@bundle//bin:rspec",
278-
data = data,
279-
tags = ["unit"],
280-
deps = ["//rb/spec/unit/selenium/webdriver:spec_helper"] + deps,
281-
visibility = ["//rb:__subpackages__"],
282-
)

rb/spec/unit/BUILD.bazel

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
load("@rules_ruby//ruby:defs.bzl", "rb_library", "rb_test")
2+
3+
rb_library(
4+
name = "spec_helper",
5+
testonly = True,
6+
srcs = ["selenium/webdriver/spec_helper.rb"],
7+
visibility = ["//rb/spec:__subpackages__"],
8+
deps = [
9+
"//rb/lib:selenium-webdriver",
10+
"//rb/lib/selenium:webdriver",
11+
"//rb/lib/selenium/webdriver:atoms",
12+
"//rb/spec:rspec_matchers",
13+
"@bundle",
14+
],
15+
)
16+
17+
rb_test(
18+
name = "unit",
19+
size = "small",
20+
srcs = glob(["**/*_spec.rb"]),
21+
args = ["rb/spec/unit/"],
22+
data = [
23+
"//third_party/firebug:favourite_colour-1.1-an+fx.xpi",
24+
"//third_party/firebug:firebug-1.5.0-fx.xpi",
25+
"//third_party/firebug:mooltipass-1.1.87.xpi",
26+
],
27+
main = "@bundle//bin:rspec",
28+
tags = ["unit"],
29+
visibility = ["//rb:__subpackages__"],
30+
deps = [
31+
":spec_helper",
32+
"//rb/lib:selenium-webdriver",
33+
"//rb/lib/selenium:devtools",
34+
"//rb/lib/selenium:server",
35+
"//rb/lib/selenium:webdriver",
36+
"//rb/lib/selenium/devtools:cdp-generate",
37+
"//rb/lib/selenium/webdriver:atoms",
38+
"//rb/lib/selenium/webdriver:bidi",
39+
"//rb/lib/selenium/webdriver:chrome",
40+
"//rb/lib/selenium/webdriver:common",
41+
"//rb/lib/selenium/webdriver:devtools",
42+
"//rb/lib/selenium/webdriver:edge",
43+
"//rb/lib/selenium/webdriver:firefox",
44+
"//rb/lib/selenium/webdriver:ie",
45+
"//rb/lib/selenium/webdriver:remote",
46+
"//rb/lib/selenium/webdriver:safari",
47+
],
48+
)

rb/spec/unit/selenium/BUILD.bazel

Lines changed: 0 additions & 26 deletions
This file was deleted.

rb/spec/unit/selenium/devtools/BUILD.bazel

Lines changed: 0 additions & 13 deletions
This file was deleted.

rb/spec/unit/selenium/webdriver/BUILD.bazel

Lines changed: 0 additions & 47 deletions
This file was deleted.

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

Lines changed: 0 additions & 10 deletions
This file was deleted.

rb/spec/unit/selenium/webdriver/chrome/BUILD.bazel

Lines changed: 0 additions & 14 deletions
This file was deleted.

rb/spec/unit/selenium/webdriver/common/BUILD.bazel

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)