Skip to content

Commit 5012e1f

Browse files
committed
merge trunk
1 parent a5c4900 commit 5012e1f

File tree

4 files changed

+108
-58
lines changed

4 files changed

+108
-58
lines changed

rb/spec/integration/selenium/webdriver/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def example_finished(notification)
7272
guards.add_condition(:headless, !ENV['HEADLESS'].nil?)
7373
guards.add_condition(:bidi, !ENV['WEBDRIVER_BIDI'].nil?)
7474
guards.add_condition(:rbe, GlobalTestEnv.rbe?)
75+
guards.add_condition(:version, GlobalTestEnv.version)
7576

7677
results = guards.disposition
7778
send(*results) if results

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ def quit_driver
8080

8181
def app_server
8282
@app_server ||= begin
83-
app_server = RackServer.new(root.join('common/src/web').to_s, random_port)
84-
app_server.start
83+
app_server = RackServer.new(root.join('common/src/web').to_s, random_port)
84+
app_server.start
8585

86-
app_server
87-
end
86+
app_server
87+
end
8888
end
8989

9090
def remote_server
@@ -119,6 +119,10 @@ def rbe?
119119
Dir.pwd.start_with?('/mnt/engflow')
120120
end
121121

122+
def version
123+
ENV['WD_BROWSER_VERSION'] |
124+
end
125+
122126
def reset_remote_server
123127
@remote_server&.stop
124128
@remote_server = nil
@@ -166,12 +170,11 @@ def root
166170
def create_driver!(listener: nil, **opts, &block)
167171
check_for_previous_error
168172

169-
method = select_driver(opts)
170-
173+
method = :"#{driver}_driver"
171174
instance = if private_methods.include?(method)
172175
send(method, listener: listener, options: build_options(**opts))
173176
else
174-
WebDriver::Driver.for(method, listener: listener, options: build_options(**opts))
177+
WebDriver::Driver.for(driver, listener: listener, options: build_options(**opts))
175178
end
176179
@create_driver_error_count -= 1 unless @create_driver_error_count.zero?
177180
if block
@@ -196,8 +199,7 @@ def build_options(**opts)
196199
if private_methods.include?(options_method)
197200
send(options_method, **opts)
198201
else
199-
parsed_browser = browser == :chrome_beta ? :chrome : browser
200-
WebDriver::Options.send(parsed_browser, **opts)
202+
WebDriver::Options.send(browser, **opts)
201203
end
202204
end
203205

@@ -315,15 +317,6 @@ def random_port
315317
ensure
316318
sock.close
317319
end
318-
319-
def select_driver(opts)
320-
if driver == :chrome_beta
321-
opts[:browser_version] = 'beta'
322-
:chrome_driver
323-
else
324-
driver
325-
end
326-
end
327320
end
328321
end # SpecSupport
329322
end # WebDriver

rb/spec/tests.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ BROWSERS = {
4040
"target_compatible_with": [],
4141
"env": {
4242
"WD_REMOTE_BROWSER": "chrome",
43-
"WD_SPEC_DRIVER": "chrome-beta",
43+
"WD_SPEC_DRIVER": "chrome",
4444
} | select({
4545
"@selenium//common:use_pinned_linux_chrome": {
4646
"CHROME_BINARY": "$(location @linux_beta_chrome//:chrome-linux64/chrome)",

scripts/pinned_browsers.py

Lines changed: 95 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def calculate_hash(url):
2626
return h.hexdigest()
2727

2828

29-
def get_chrome_milestone(channel=None):
30-
if channel is None:
31-
parser = argparse.ArgumentParser()
32-
parser.add_argument('--chrome_channel', default='Stable', help='Set the Chrome channel')
33-
args = parser.parse_args()
34-
channel = args.chrome_channel
29+
def get_chrome_milestone():
30+
parser = argparse.ArgumentParser()
31+
parser.add_argument('--chrome_channel', default='Stable', help='Set the Chrome channel')
32+
args = parser.parse_args()
33+
channel = args.chrome_channel
34+
3535
r = http.request(
3636
"GET", f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux"
3737
)
@@ -48,15 +48,18 @@ def get_chrome_milestone(channel=None):
4848
)[-1]
4949

5050

51-
def chromedriver(selected_version, workspace_prefix=""):
51+
def chromedriver(selected_version):
5252
content = ""
5353

5454
drivers = selected_version["downloads"]["chromedriver"]
5555

5656
linux = [d["url"] for d in drivers if d["platform"] == "linux64"][0]
5757
sha = calculate_hash(linux)
58-
content = content + """ http_archive(
59-
name = "linux_%schromedriver",
58+
59+
content = (
60+
content
61+
+ """ http_archive(
62+
name = "linux_chromedriver",
6063
url = "%s",
6164
sha256 = "%s",
6265
strip_prefix = "chromedriver-linux64",
@@ -72,12 +75,17 @@ def chromedriver(selected_version, workspace_prefix=""):
7275
)
7376
\"\"\",
7477
)
75-
""" % (workspace_prefix, linux, sha)
78+
"""
79+
% (linux, sha)
80+
)
81+
7682
mac = [d["url"] for d in drivers if d["platform"] == "mac-x64"][0]
7783
sha = calculate_hash(mac)
78-
content = content + """
84+
content = (
85+
content
86+
+ """
7987
http_archive(
80-
name = "mac_%schromedriver",
88+
name = "mac_chromedriver",
8189
url = "%s",
8290
sha256 = "%s",
8391
strip_prefix = "chromedriver-mac-x64",
@@ -93,19 +101,22 @@ def chromedriver(selected_version, workspace_prefix=""):
93101
)
94102
\"\"\",
95103
)
96-
""" % (workspace_prefix, mac, sha)
104+
"""
105+
% (mac, sha)
106+
)
107+
97108
return content
98109

99110

100-
def chrome(selected_version, workspace_prefix=""):
111+
def chrome(selected_version):
101112
chrome_downloads = selected_version["downloads"]["chrome"]
102113

103114
linux = [d["url"] for d in chrome_downloads if d["platform"] == "linux64"][0]
104115
sha = calculate_hash(linux)
105116

106117
content = """
107118
http_archive(
108-
name = "linux_%schrome",
119+
name = "linux_chrome",
109120
url = "%s",
110121
sha256 = "%s",
111122
build_file_content = \"\"\"
@@ -126,11 +137,16 @@ def chrome(selected_version, workspace_prefix=""):
126137
\"\"\",
127138
)
128139
129-
""" % (workspace_prefix, linux, sha)
140+
""" % (
141+
linux,
142+
sha,
143+
)
144+
130145
mac = [d["url"] for d in chrome_downloads if d["platform"] == "mac-x64"][0]
131146
sha = calculate_hash(mac)
147+
132148
content += """ http_archive(
133-
name = "mac_%schrome",
149+
name = "mac_chrome",
134150
url = "%s",
135151
sha256 = "%s",
136152
strip_prefix = "chrome-mac-x64",
@@ -151,7 +167,11 @@ def chrome(selected_version, workspace_prefix=""):
151167
\"\"\",
152168
)
153169
154-
""" % (workspace_prefix, mac, sha)
170+
""" % (
171+
mac,
172+
sha,
173+
)
174+
155175
return content
156176

157177

@@ -217,7 +237,12 @@ def edge():
217237
)
218238
\"\"\",
219239
)
220-
""" % (mac, mac_hash.lower(), mac_version)
240+
""" % (
241+
mac,
242+
mac_hash.lower(),
243+
mac_version,
244+
)
245+
221246
if linux and linux_hash:
222247
content += """
223248
deb_archive(
@@ -241,7 +266,11 @@ def edge():
241266
)
242267
\"\"\",
243268
)
244-
""" % (linux, linux_hash.lower())
269+
""" % (
270+
linux,
271+
linux_hash.lower()
272+
)
273+
245274
return content
246275

247276

@@ -256,7 +285,9 @@ def edgedriver():
256285

257286
linux = "https://msedgedriver.azureedge.net/%s/edgedriver_linux64.zip" % linux_version
258287
sha = calculate_hash(linux)
259-
content = content + """
288+
content = (
289+
content
290+
+ """
260291
http_archive(
261292
name = "linux_edgedriver",
262293
url = "%s",
@@ -273,12 +304,17 @@ def edgedriver():
273304
)
274305
\"\"\",
275306
)
276-
""" % (linux, sha)
307+
"""
308+
% (linux, sha)
309+
)
310+
277311
r = http.request("GET", f"https://msedgedriver.azureedge.net/LATEST_RELEASE_{major_version}_MACOS")
278312
macos_version = r.data.decode("utf-16").strip()
279313
mac = "https://msedgedriver.azureedge.net/%s/edgedriver_mac64.zip" % macos_version
280314
sha = calculate_hash(mac)
281-
content = content + """
315+
content = (
316+
content
317+
+ """
282318
http_archive(
283319
name = "mac_edgedriver",
284320
url = "%s",
@@ -295,7 +331,9 @@ def edgedriver():
295331
)
296332
\"\"\",
297333
)
298-
""" % (mac, sha)
334+
"""
335+
% (mac, sha)
336+
)
299337
return content
300338

301339

@@ -307,7 +345,9 @@ def geckodriver():
307345
if a["name"].endswith("-linux64.tar.gz"):
308346
url = a["browser_download_url"]
309347
sha = calculate_hash(url)
310-
content = content + """ http_archive(
348+
content = (
349+
content
350+
+ """ http_archive(
311351
name = "linux_geckodriver",
312352
url = "%s",
313353
sha256 = "%s",
@@ -323,11 +363,16 @@ def geckodriver():
323363
)
324364
\"\"\",
325365
)
326-
""" % (url, sha)
366+
"""
367+
% (url, sha)
368+
)
369+
327370
if a["name"].endswith("-macos.tar.gz"):
328371
url = a["browser_download_url"]
329372
sha = calculate_hash(url)
330-
content = content + """
373+
content = (
374+
content
375+
+ """
331376
http_archive(
332377
name = "mac_geckodriver",
333378
url = "%s",
@@ -344,7 +389,9 @@ def geckodriver():
344389
)
345390
\"\"\",
346391
)
347-
""" % (url, sha)
392+
"""
393+
% (url, sha)
394+
)
348395
return content
349396

350397

@@ -370,9 +417,11 @@ def firefox_version_data():
370417

371418
def firefox_linux(version):
372419
if int(version.split(".")[0]) < 135:
373-
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.bz2" % (version, version)
420+
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.bz2" % (
421+
version, version)
374422
else:
375-
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.xz" % (version, version)
423+
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.xz" % (
424+
version, version)
376425

377426

378427
def firefox_mac(version):
@@ -381,7 +430,10 @@ def firefox_mac(version):
381430

382431
def print_firefox(version, workspace_name, sha_linux, sha_mac):
383432
content = ""
384-
content = content + f""" http_archive(
433+
434+
content = (
435+
content
436+
+ f""" http_archive(
385437
name = "linux_{workspace_name}firefox",
386438
url = "{firefox_linux(version)}",
387439
sha256 = "{sha_linux}",
@@ -404,7 +456,11 @@ def print_firefox(version, workspace_name, sha_linux, sha_mac):
404456
)
405457
406458
"""
407-
content = content + f""" dmg_archive(
459+
)
460+
461+
content = (
462+
content
463+
+ f""" dmg_archive(
408464
name = "mac_{workspace_name}firefox",
409465
url = "{firefox_mac(version)}",
410466
sha256 = "{sha_mac}",
@@ -422,6 +478,8 @@ def print_firefox(version, workspace_name, sha_linux, sha_mac):
422478
)
423479
424480
"""
481+
)
482+
425483
return content
426484

427485

@@ -442,13 +500,9 @@ def pin_browsers():
442500
content = content + geckodriver()
443501
content = content + edge()
444502
content = content + edgedriver()
445-
chrome_stable = get_chrome_milestone("Stable")
446-
content = content + chrome(chrome_stable, "")
447-
content = content + chromedriver(chrome_stable, "")
448-
chrome_beta = get_chrome_milestone("Beta")
449-
if chrome_beta["version"] != chrome_stable["version"]:
450-
content = content + chrome(chrome_beta, "beta_")
451-
content = content + chromedriver(chrome_beta, "beta_")
503+
chrome_milestone = get_chrome_milestone()
504+
content = content + chrome(chrome_milestone)
505+
content = content + chromedriver(chrome_milestone)
452506
content += """
453507
def _pin_browsers_extension_impl(_ctx):
454508
pin_browsers()
@@ -457,7 +511,9 @@ def _pin_browsers_extension_impl(_ctx):
457511
implementation = _pin_browsers_extension_impl,
458512
)
459513
"""
514+
460515
current_script_dir = Path(os.path.realpath(__file__)).parent
461516
target_file_path = current_script_dir.parent / "common/repositories.bzl"
517+
462518
with open(target_file_path, "w") as file:
463519
file.write(content)

0 commit comments

Comments
 (0)