зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1498330 [wpt PR 13467] - Extract Safari version from safaridriver, a=testonly
Automatic update from web-platform-testsExtract Safari version from safaridriver (#13467) -- wpt-commits: bd9dbc0d99bdadc541cd55a0309730d2bf40df1b wpt-pr: 13467
This commit is contained in:
Родитель
b93a754b67
Коммит
9087c02e28
|
@ -46,7 +46,7 @@ class Browser(object):
|
|||
return NotImplemented
|
||||
|
||||
@abstractmethod
|
||||
def version(self, binary=None):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
"""Retrieve the release version of the installed browser."""
|
||||
return NotImplemented
|
||||
|
||||
|
@ -367,7 +367,7 @@ class Firefox(Browser):
|
|||
|
||||
return path
|
||||
|
||||
def version(self, binary=None):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
"""Retrieve the release version of the installed browser."""
|
||||
version_string = call(binary, "--version").strip()
|
||||
m = re.match(r"Mozilla Firefox (.*)", version_string)
|
||||
|
@ -394,7 +394,7 @@ class Fennec(Browser):
|
|||
def install_webdriver(self, dest=None, channel=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def version(self, binary=None):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
return None
|
||||
|
||||
|
||||
|
@ -458,7 +458,7 @@ class Chrome(Browser):
|
|||
os.chmod(path, st.st_mode | stat.S_IEXEC)
|
||||
return path
|
||||
|
||||
def version(self, binary=None):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
binary = binary or self.binary
|
||||
if uname[0] != "Windows":
|
||||
try:
|
||||
|
@ -497,7 +497,7 @@ class ChromeAndroid(Browser):
|
|||
chrome = Chrome()
|
||||
return chrome.install_webdriver(dest, channel)
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
return None
|
||||
|
||||
|
||||
|
@ -563,7 +563,7 @@ class Opera(Browser):
|
|||
os.chmod(path, st.st_mode | stat.S_IEXEC)
|
||||
return path
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
"""Retrieve the release version of the installed browser."""
|
||||
binary = binary or self.binary
|
||||
try:
|
||||
|
@ -594,7 +594,7 @@ class Edge(Browser):
|
|||
def install_webdriver(self, dest=None, channel=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
return None
|
||||
|
||||
|
||||
|
@ -620,7 +620,7 @@ class InternetExplorer(Browser):
|
|||
def install_webdriver(self, dest=None, channel=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
return None
|
||||
|
||||
|
||||
|
@ -648,8 +648,24 @@ class Safari(Browser):
|
|||
def install_webdriver(self, dest=None, channel=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
if webdriver_binary is None:
|
||||
logger.warn("Cannot find Safari version without safaridriver")
|
||||
return None
|
||||
# Use `safaridriver --version` to get the version. Example output:
|
||||
# "Included with Safari 12.1 (14607.1.11)"
|
||||
# "Included with Safari Technology Preview (Release 67, 13607.1.9.0.1)"
|
||||
# The `--version` flag was added in STP 67, so allow the call to fail.
|
||||
try:
|
||||
version_string = call(webdriver_binary, "--version").strip()
|
||||
except subprocess.CalledProcessError:
|
||||
logger.warn("Failed to call %s --version", webdriver_binary)
|
||||
return None
|
||||
m = re.match(r"Included with Safari (.*)", version_string)
|
||||
if not m:
|
||||
logger.warn("Failed to extract version from: s%", version_string)
|
||||
return None
|
||||
return m.group(1)
|
||||
|
||||
|
||||
class SafariWebDriver(Safari):
|
||||
|
@ -708,7 +724,7 @@ class Servo(Browser):
|
|||
def install_webdriver(self, dest=None, channel=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
"""Retrieve the release version of the installed browser."""
|
||||
output = call(binary, "--version")
|
||||
m = re.search(r"Servo ([0-9\.]+-[a-f0-9]+)?(-dirty)?$", output.strip())
|
||||
|
@ -738,7 +754,7 @@ class Sauce(Browser):
|
|||
def install_webdriver(self, dest=None, channel=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
return None
|
||||
|
||||
|
||||
|
@ -760,5 +776,5 @@ class WebKit(Browser):
|
|||
def install_webdriver(self, dest=None, channel=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def version(self, binary):
|
||||
def version(self, binary=None, webdriver_binary=None):
|
||||
return None
|
||||
|
|
|
@ -509,7 +509,8 @@ def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs):
|
|||
|
||||
venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt"))
|
||||
|
||||
kwargs['browser_version'] = setup_cls.browser.version(kwargs.get("binary"))
|
||||
kwargs['browser_version'] = setup_cls.browser.version(binary=kwargs.get("binary"),
|
||||
webdriver_binary=kwargs.get("webdriver_binary"))
|
||||
return kwargs
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import mock
|
||||
import subprocess
|
||||
|
||||
from tools.wpt import browser
|
||||
|
||||
@mock.patch('subprocess.check_output')
|
||||
def test_safari_version(mocked_check_output):
|
||||
safari = browser.Safari()
|
||||
|
||||
# Safari
|
||||
mocked_check_output.return_value = 'Included with Safari 12.1 (14607.1.11)'
|
||||
assert safari.version(webdriver_binary="safaridriver") == '12.1 (14607.1.11)'
|
||||
|
||||
# Safari Technology Preview
|
||||
mocked_check_output.return_value = 'Included with Safari Technology Preview (Release 67, 13607.1.9.0.1)'
|
||||
assert safari.version(webdriver_binary="safaridriver") == 'Technology Preview (Release 67, 13607.1.9.0.1)'
|
||||
|
||||
@mock.patch('subprocess.check_output')
|
||||
def test_safari_version_errors(mocked_check_output):
|
||||
safari = browser.Safari()
|
||||
|
||||
# No webdriver_binary
|
||||
assert safari.version() is None
|
||||
|
||||
# `safaridriver --version` return gibberish
|
||||
mocked_check_output.return_value = 'gibberish'
|
||||
assert safari.version(webdriver_binary="safaridriver") is None
|
||||
|
||||
# `safaridriver --version` fails (as it does for Safari <=12.0)
|
||||
mocked_check_output.return_value = 'dummy'
|
||||
mocked_check_output.side_effect = subprocess.CalledProcessError(1, 'cmd')
|
||||
assert safari.version(webdriver_binary="safaridriver") is None
|
|
@ -57,9 +57,9 @@ def test_setup_wptrunner(venv, product):
|
|||
parser = run.create_parser()
|
||||
kwargs = vars(parser.parse_args(["--channel=nightly", product]))
|
||||
kwargs["prompt"] = False
|
||||
kwargs["webdriver_binary"] = "fake"
|
||||
# Hack to get a real existing path
|
||||
kwargs["binary"] = sys.argv[0]
|
||||
kwargs["webdriver_binary"] = sys.argv[0]
|
||||
if kwargs["product"] == "sauce":
|
||||
kwargs["product"] = "sauce:firefox:63"
|
||||
run.setup_wptrunner(venv, **kwargs)
|
||||
|
|
Загрузка…
Ссылка в новой задаче