Skip to content

Commit fba3e40

Browse files
committed
Added support for safaridriver
1 parent 65b2155 commit fba3e40

25 files changed

+611
-483
lines changed

.bazelci/presubmit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ tasks:
10741074
name: Extensions wasm-bindgen
10751075
working_directory: extensions/wasm_bindgen
10761076
shell_commands:
1077-
- "bash ./test/bazelci_linux_setup.sh"
1077+
- "bash ./test/bazelci_unix_setup.sh"
10781078
build_flags: *aspects_flags
10791079
test_flags: *aspects_flags
10801080
build_targets:
@@ -1099,6 +1099,8 @@ tasks:
10991099
platform: macos_arm64
11001100
name: Extensions wasm-bindgen
11011101
working_directory: extensions/wasm_bindgen
1102+
shell_commands:
1103+
- "bash ./test/bazelci_unix_setup.sh"
11021104
build_flags: *aspects_flags
11031105
test_flags: *aspects_flags
11041106
build_targets:
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
bcr_test_module:
22
module_path: ""
33
matrix:
4-
platform: ["macos_arm64", "windows"]
4+
platform: ["macos_arm64", "ubuntu2004", "windows"]
55
bazel: ["7.x", "8.x"]
66
tasks:
77
run_tests:
88
name: "Run test module"
99
platform: ${{ platform }}
1010
bazel: ${{ bazel }}
11-
test_targets:
12-
- "//..."
13-
bcr_test_module_linux:
14-
module_path: ""
15-
matrix:
16-
platform: ["ubuntu2004"]
17-
bazel: ["7.x", "8.x"]
18-
tasks:
19-
run_tests:
2011
shell_commands:
21-
- "bash ./test/bazelci_linux_setup.sh"
22-
name: "Run test module"
23-
platform: ${{ platform }}
24-
bazel: ${{ bazel }}
12+
- "bash ./test/bazelci_unix_setup.sh"
2513
test_targets:
2614
- "//..."

extensions/wasm_bindgen/.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ build:firefox --//settings:test_browser=firefox
3535
# Explicitly use chrome for browser tests
3636
build:chrome --//settings:test_browser=chrome
3737

38+
# Explicitly use safari for browser tests
39+
build:safari --//settings:test_browser=safari
40+
3841
# Default linux to run firefox
3942
build:linux --config=firefox
43+
build:macos --config=safari
4044

4145
# Enable use of the nightly toolchains.
4246
build:nightly --@rules_rust//rust/toolchain/channel=nightly

extensions/wasm_bindgen/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ rust_wasm_bindgen_toolchain(
2727
browser = select({
2828
"//settings:test_browser_chrome": "@chrome",
2929
"//settings:test_browser_firefox": "@firefox",
30+
"//settings:test_browser_safari": None,
3031
}),
3132
browser_type = select({
3233
"//settings:test_browser_chrome": "chrome",
3334
"//settings:test_browser_firefox": "firefox",
35+
"//settings:test_browser_safari": "safari",
3436
}),
3537
visibility = ["//visibility:public"],
3638
wasm_bindgen_cli = "//3rdparty:wasm_bindgen_cli",
@@ -39,10 +41,12 @@ rust_wasm_bindgen_toolchain(
3941
webdriver = select({
4042
"//settings:test_browser_chrome": "@chromedriver",
4143
"//settings:test_browser_firefox": "@geckodriver",
44+
"//settings:test_browser_safari": "@safaridriver",
4245
}),
4346
webdriver_args = select({
4447
"//settings:test_browser_chrome": ["--verbose"],
4548
"//settings:test_browser_firefox": [],
49+
"//settings:test_browser_safari": [],
4650
}),
4751
webdriver_json = "webdriver.json",
4852
)

extensions/wasm_bindgen/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ use_repo(
6666
"rrwbd__wasmparser-0.214.0",
6767
"rrwbd__wasmprinter-0.214.0",
6868
"rules_rust_wasm_bindgen_cli",
69+
"safaridriver",
6970
)
7071

7172
register_toolchains(

extensions/wasm_bindgen/private/wasm_bindgen.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ For additional information, see the [Bazel toolchains documentation][toolchains]
282282
values = [
283283
"firefox",
284284
"chrome",
285+
"safari",
285286
],
286287
),
287288
"wasm_bindgen_cli": attr.label(

extensions/wasm_bindgen/private/wasm_bindgen_test_wrapper.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,27 @@ use runfiles::{rlocation, Runfiles};
1010

1111
fn write_webdriver_for_browser(
1212
original: &Path,
13-
section: &str,
13+
section: Option<&str>,
1414
args: &Vec<String>,
1515
browser: &Option<PathBuf>,
1616
output: &Path,
1717
) {
18+
// If no section is provided, simply copy the file and early return.
19+
let section = match section {
20+
Some(s) => s,
21+
None => {
22+
fs::copy(original, output).unwrap_or_else(|e| {
23+
panic!(
24+
"Failed to copy webdriver config: {} -> {}\n{:?}",
25+
original.display(),
26+
output.display(),
27+
e
28+
);
29+
});
30+
return;
31+
}
32+
};
33+
1834
let content = fs::read_to_string(original).unwrap_or_else(|e| {
1935
panic!(
2036
"Failed to read webdriver.json at: {}\n{:?}",
@@ -135,7 +151,7 @@ fn main() {
135151

136152
write_webdriver_for_browser(
137153
&webdriver_json,
138-
"goog:chromeOptions",
154+
Some("goog:chromeOptions"),
139155
&vec![format!("user-data-dir={}", user_data_dir.display())],
140156
&browser,
141157
&updated_webdriver_json,
@@ -151,7 +167,7 @@ fn main() {
151167

152168
write_webdriver_for_browser(
153169
&webdriver_json,
154-
"moz:firefoxOptions",
170+
Some("moz:firefoxOptions"),
155171
&Vec::new(),
156172
&browser,
157173
&updated_webdriver_json,
@@ -163,6 +179,17 @@ fn main() {
163179

164180
env.insert("GECKODRIVER_ARGS".to_string(), webdriver_args);
165181
}
182+
"safari" => {
183+
write_webdriver_for_browser(
184+
&webdriver_json,
185+
None,
186+
&Vec::new(),
187+
&browser,
188+
&updated_webdriver_json,
189+
);
190+
191+
env.insert("SAFARIDRIVER_ARGS".to_string(), webdriver_args);
192+
}
166193
_ => {
167194
panic!("Unexpected browser type: {}", browser_type)
168195
}

extensions/wasm_bindgen/private/webdrivers/BUILD.bazel

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
22

3-
exports_files([
4-
"firefox",
5-
"chrome",
6-
])
7-
83
bzl_library(
94
name = "bzl_lib",
105
srcs = glob(["*.bzl"]),

extensions/wasm_bindgen/private/webdrivers/chrome/BUILD.bazel

Whitespace-only changes.
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
"""Depednencies for `wasm_bindgen_test` rules"""
2+
3+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
4+
load("//private/webdrivers:webdriver_utils.bzl", "build_file_repository", "webdriver_repository")
5+
6+
# A snippet from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
7+
# but modified to included `integrity`
8+
CHROME_DATA = {
9+
"downloads": {
10+
"chrome": [
11+
{
12+
"integrity": "sha256-fm2efJlMZRGqLP7dgfMqhz6CKY/qVJrO6lfDZLLhA/k=",
13+
"platform": "linux64",
14+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/linux64/chrome-linux64.zip",
15+
},
16+
{
17+
"integrity": "sha256-uROIJ56CjR6ZyjiwPCAB7n21aSoA3Wi6TluPnAch8YM=",
18+
"platform": "mac-arm64",
19+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-arm64/chrome-mac-arm64.zip",
20+
},
21+
{
22+
"integrity": "sha256-e9rzOOF8n43J5IpwvBQjnKyGc26QnBcTygpALtGDCK0=",
23+
"platform": "mac-x64",
24+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-x64/chrome-mac-x64.zip",
25+
},
26+
{
27+
"integrity": "sha256-tp67N9Iy0WPqRBqCPG66ow/TTEcBuSuS/XsJwms253Q=",
28+
"platform": "win32",
29+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win32/chrome-win32.zip",
30+
},
31+
{
32+
"integrity": "sha256-GhiJkB9FcXIxdIqWf2gsJh0jYLWzx2V2r3wWLRcwSSk=",
33+
"platform": "win64",
34+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win64/chrome-win64.zip",
35+
},
36+
],
37+
"chrome-headless-shell": [
38+
{
39+
"integrity": "sha256-ZfahmT+jnxYV7e6e62Fj5W32FPJryOgAmhVDjNDp0Hk=",
40+
"platform": "linux64",
41+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/linux64/chrome-headless-shell-linux64.zip",
42+
},
43+
{
44+
"integrity": "sha256-Rfdu/e4raKeTCvh5FgK4H6rrAG14KRWK4fAzoOrqUBQ=",
45+
"platform": "mac-arm64",
46+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-arm64/chrome-headless-shell-mac-arm64.zip",
47+
},
48+
{
49+
"integrity": "sha256-TWHvAfeYDKifKQD95rSantkCtpR3vLKraP41VnlGFmA=",
50+
"platform": "mac-x64",
51+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-x64/chrome-headless-shell-mac-x64.zip",
52+
},
53+
{
54+
"integrity": "sha256-KuWJUK12L+K4sQwRRecq0qrqz4CLDqPkN3c31vpMLXI=",
55+
"platform": "win32",
56+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win32/chrome-headless-shell-win32.zip",
57+
},
58+
{
59+
"integrity": "sha256-9ZoAYNyG2yu/QQLNqVjbBMjrj5WtaSm62Ydp8u4BXqk=",
60+
"platform": "win64",
61+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win64/chrome-headless-shell-win64.zip",
62+
},
63+
],
64+
"chromedriver": [
65+
{
66+
"integrity": "sha256-FB1JYbgukDV7/PngapsD7b09XcqO5h01VFtTGPq6has=",
67+
"platform": "linux64",
68+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/linux64/chromedriver-linux64.zip",
69+
},
70+
{
71+
"integrity": "sha256-ZATjVJV7PsswgvgdT7zQeeC6pgflX6qcrQmHxwY+/xE=",
72+
"platform": "mac-arm64",
73+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-arm64/chromedriver-mac-arm64.zip",
74+
},
75+
{
76+
"integrity": "sha256-8IsY85x99wA1VtRY5K1vB9hB0tJtzPgfNJaLYEUk7mw=",
77+
"platform": "mac-x64",
78+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/mac-x64/chromedriver-mac-x64.zip",
79+
},
80+
{
81+
"integrity": "sha256-HYamG2SqvfrCLbxaQIc8CI5x1KnZ/XkJ0Y3RKwmFaDo=",
82+
"platform": "win32",
83+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win32/chromedriver-win32.zip",
84+
},
85+
{
86+
"integrity": "sha256-IxvDZCKGBTZkYDT/M7XQOfI/DaQxA9yYPJ0PB5XniVQ=",
87+
"platform": "win64",
88+
"url": "https://storage.googleapis.com/chrome-for-testing-public/136.0.7055.0/win64/chromedriver-win64.zip",
89+
},
90+
],
91+
},
92+
"revision": "1429446",
93+
"version": "136.0.7055.0",
94+
}
95+
96+
def chrome_deps():
97+
"""Download chromedriver dependencies
98+
99+
Returns:
100+
A list of repositories crated
101+
"""
102+
103+
direct_deps = []
104+
for data in CHROME_DATA["downloads"]["chromedriver"]:
105+
platform = data["platform"]
106+
name = "chromedriver_{}".format(platform.replace("-", "_"))
107+
direct_deps.append(struct(repo = name))
108+
tool = "chromedriver"
109+
if platform.startswith("win"):
110+
tool = "chromedriver.exe"
111+
maybe(
112+
webdriver_repository,
113+
name = name,
114+
original_name = name,
115+
urls = [data["url"]],
116+
strip_prefix = "chromedriver-{}".format(platform),
117+
integrity = data.get("integrity", ""),
118+
tool = tool,
119+
)
120+
121+
for data in CHROME_DATA["downloads"]["chrome-headless-shell"]:
122+
platform = data["platform"]
123+
name = "chrome_headless_shell_{}".format(platform.replace("-", "_"))
124+
direct_deps.append(struct(repo = name))
125+
tool = "chrome-headless-shell"
126+
if platform.startswith("win"):
127+
tool = "chrome-headless-shell.exe"
128+
maybe(
129+
webdriver_repository,
130+
name = name,
131+
original_name = name,
132+
urls = [data["url"]],
133+
strip_prefix = "chrome-headless-shell-{}".format(platform),
134+
integrity = data.get("integrity", ""),
135+
tool = tool,
136+
)
137+
138+
for data in CHROME_DATA["downloads"]["chrome"]:
139+
platform = data["platform"]
140+
name = "chrome_{}".format(platform.replace("-", "_"))
141+
direct_deps.append(struct(repo = name))
142+
143+
if platform.startswith("win"):
144+
tool = "chrome.exe"
145+
elif platform.startswith("mac"):
146+
tool = "Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
147+
else:
148+
tool = "chrome"
149+
maybe(
150+
webdriver_repository,
151+
name = name,
152+
original_name = name,
153+
urls = [data["url"]],
154+
strip_prefix = "chrome-{}".format(platform),
155+
integrity = data.get("integrity", ""),
156+
tool = tool,
157+
)
158+
159+
direct_deps.append(struct(repo = "chromedriver"))
160+
maybe(
161+
build_file_repository,
162+
name = "chromedriver",
163+
build_file = Label("//private/webdrivers/chrome:BUILD.chromedriver.bazel"),
164+
)
165+
166+
direct_deps.append(struct(repo = "chrome_headless_shell"))
167+
maybe(
168+
build_file_repository,
169+
name = "chrome_headless_shell",
170+
build_file = Label("//private/webdrivers/chrome:BUILD.chrome_headless_shell.bazel"),
171+
)
172+
173+
direct_deps.append(struct(repo = "chrome"))
174+
maybe(
175+
build_file_repository,
176+
name = "chrome",
177+
build_file = Label("//private/webdrivers/chrome:BUILD.chrome.bazel"),
178+
)
179+
180+
return direct_deps

extensions/wasm_bindgen/private/webdrivers/firefox/BUILD.bazel

Whitespace-only changes.

0 commit comments

Comments
 (0)