зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1655512 [wpt PR 24766] - [wpt] Fix the installation of ChromeDriver stable, a=testonly
Automatic update from web-platform-tests [wpt] Fix the installation of ChromeDriver stable (#24766) This was accidentally regressed in #24702 due to lack of comments or tests, both of which are also added in this change. Fixes #24753. -- wpt-commits: 93f60af091e034be401e3915c3d699d495e7a5ea wpt-pr: 24766
This commit is contained in:
Родитель
1cf4b2fcc9
Коммит
359b4c8192
|
@ -680,13 +680,21 @@ class Chrome(Browser):
|
|||
else self._chromium_chromedriver_url(None)
|
||||
self.logger.info("Downloading ChromeDriver from %s" % url)
|
||||
unzip(get(url).raw, dest)
|
||||
|
||||
# The two sources of ChromeDriver have different zip structures:
|
||||
# * Chromium archives the binary inside a chromedriver_* directory;
|
||||
# * Chrome archives the binary directly.
|
||||
# We want to make sure the binary always ends up directly in bin/.
|
||||
chromedriver_dir = os.path.join(
|
||||
dest, 'chromedriver_%s' % self._chromedriver_platform_string())
|
||||
unzipped_path = find_executable("chromedriver", chromedriver_dir)
|
||||
assert unzipped_path is not None
|
||||
shutil.move(unzipped_path, dest)
|
||||
rmtree(chromedriver_dir)
|
||||
return find_executable("chromedriver", dest)
|
||||
binary_path = find_executable("chromedriver", chromedriver_dir)
|
||||
if binary_path is not None:
|
||||
shutil.move(binary_path, dest)
|
||||
rmtree(chromedriver_dir)
|
||||
|
||||
binary_path = find_executable("chromedriver", dest)
|
||||
assert binary_path is not None
|
||||
return binary_path
|
||||
|
||||
def install_webdriver(self, dest=None, channel=None, browser_binary=None):
|
||||
if channel == "nightly":
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.wpt import browser, utils, wpt
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.remote_network
|
||||
def test_install_chromium():
|
||||
if sys.platform == "win32":
|
||||
chromium_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "chrome-win")
|
||||
elif sys.platform == "darwin":
|
||||
chromium_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "chrome-mac")
|
||||
else:
|
||||
chromium_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "chrome-linux")
|
||||
|
||||
if os.path.exists(chromium_path):
|
||||
utils.rmtree(chromium_path)
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
wpt.main(argv=["install", "chrome", "browser", "--channel=nightly"])
|
||||
assert excinfo.value.code == 0
|
||||
assert os.path.exists(chromium_path)
|
||||
utils.rmtree(chromium_path)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.remote_network
|
||||
def test_install_chromedriver_official():
|
||||
# This is not technically an integration test as we do not want to require Chrome Stable to run it.
|
||||
chrome = browser.Chrome(logging.getLogger("Chrome"))
|
||||
if sys.platform == "win32":
|
||||
dest = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "Scripts")
|
||||
chromedriver_path = os.path.join(dest, "chromedriver.exe")
|
||||
else:
|
||||
dest = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "bin")
|
||||
chromedriver_path = os.path.join(dest, "chromedriver")
|
||||
if os.path.exists(chromedriver_path):
|
||||
os.unlink(chromedriver_path)
|
||||
# This is a stable version.
|
||||
binary_path = chrome.install_webdriver_by_version("84.0.4147.89", dest=dest)
|
||||
assert binary_path == chromedriver_path
|
||||
assert os.path.exists(chromedriver_path)
|
||||
os.unlink(chromedriver_path)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.remote_network
|
||||
def test_install_chromedriver_nightly():
|
||||
if sys.platform == "win32":
|
||||
chromedriver_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "Scripts", "chromedriver.exe")
|
||||
else:
|
||||
chromedriver_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "bin", "chromedriver")
|
||||
if os.path.exists(chromedriver_path):
|
||||
os.unlink(chromedriver_path)
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
wpt.main(argv=["install", "chrome", "webdriver"])
|
||||
assert excinfo.value.code == 0
|
||||
assert os.path.exists(chromedriver_path)
|
||||
# FIXME: On Windows, this may sometimes fail (access denied), possibly
|
||||
# because the file handler is not released immediately.
|
||||
try:
|
||||
os.unlink(chromedriver_path)
|
||||
except OSError:
|
||||
if sys.platform != "win32":
|
||||
raise
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.remote_network
|
||||
@pytest.mark.xfail(sys.platform == "win32",
|
||||
reason="https://github.com/web-platform-tests/wpt/issues/17074")
|
||||
def test_install_firefox():
|
||||
if sys.platform == "darwin":
|
||||
fx_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "Firefox Nightly.app")
|
||||
else:
|
||||
fx_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "firefox")
|
||||
if os.path.exists(fx_path):
|
||||
utils.rmtree(fx_path)
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
wpt.main(argv=["install", "firefox", "browser", "--channel=nightly"])
|
||||
assert excinfo.value.code == 0
|
||||
assert os.path.exists(fx_path)
|
||||
utils.rmtree(fx_path)
|
|
@ -239,65 +239,6 @@ def test_run_verify_unstable(temp_test):
|
|||
assert excinfo.value.code == 0
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.remote_network
|
||||
def test_install_chromium():
|
||||
if sys.platform == "win32":
|
||||
chromium_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "chrome-win")
|
||||
elif sys.platform == "darwin":
|
||||
chromium_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "chrome-mac")
|
||||
else:
|
||||
chromium_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "chrome-linux")
|
||||
|
||||
if os.path.exists(chromium_path):
|
||||
utils.rmtree(chromium_path)
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
wpt.main(argv=["install", "chrome", "browser", "--channel=nightly"])
|
||||
assert excinfo.value.code == 0
|
||||
assert os.path.exists(chromium_path)
|
||||
utils.rmtree(chromium_path)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.remote_network
|
||||
def test_install_chromedriver():
|
||||
if sys.platform == "win32":
|
||||
chromedriver_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "Scripts", "chromedriver.exe")
|
||||
else:
|
||||
chromedriver_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "bin", "chromedriver")
|
||||
if os.path.exists(chromedriver_path):
|
||||
os.unlink(chromedriver_path)
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
wpt.main(argv=["install", "chrome", "webdriver"])
|
||||
assert excinfo.value.code == 0
|
||||
assert os.path.exists(chromedriver_path)
|
||||
# FIXME: On Windows, this may sometimes fail (access denied), possibly
|
||||
# because the file handler is not released immediately.
|
||||
try:
|
||||
os.unlink(chromedriver_path)
|
||||
except OSError:
|
||||
if sys.platform != "win32":
|
||||
raise
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.remote_network
|
||||
@pytest.mark.xfail(sys.platform == "win32",
|
||||
reason="https://github.com/web-platform-tests/wpt/issues/17074")
|
||||
def test_install_firefox():
|
||||
if sys.platform == "darwin":
|
||||
fx_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "Firefox Nightly.app")
|
||||
else:
|
||||
fx_path = os.path.join(wpt.localpaths.repo_root, wpt.venv_dir(), "browsers", "nightly", "firefox")
|
||||
if os.path.exists(fx_path):
|
||||
utils.rmtree(fx_path)
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
wpt.main(argv=["install", "firefox", "browser", "--channel=nightly"])
|
||||
assert excinfo.value.code == 0
|
||||
assert os.path.exists(fx_path)
|
||||
utils.rmtree(fx_path)
|
||||
|
||||
|
||||
def test_files_changed(capsys):
|
||||
commit = "9047ac1d9f51b1e9faa4f9fad9c47d109609ab09"
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
|
|
|
@ -107,7 +107,7 @@ def rmtree(path):
|
|||
# hasn't been fully released (a common issue).
|
||||
def handle_remove_readonly(func, path, exc):
|
||||
excvalue = exc[1]
|
||||
if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
|
||||
if func in (os.rmdir, os.remove, os.unlink) and excvalue.errno == errno.EACCES:
|
||||
os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777
|
||||
func(path)
|
||||
else:
|
||||
|
|
Загрузка…
Ссылка в новой задаче