Skip to content

Commit

Permalink
Extract Safari version from safaridriver
Browse files Browse the repository at this point in the history
  • Loading branch information
foolip committed Oct 23, 2018
1 parent a252e9f commit a35a216
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
38 changes: 24 additions & 14 deletions tools/wpt/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def find_webdriver(self, channel=None):
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

Expand Down Expand Up @@ -366,8 +366,7 @@ def install_geckodriver_nightly(self, dest):
os.unlink(package_path)

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)
Expand All @@ -394,7 +393,7 @@ def find_webdriver(self, channel=None):
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


Expand Down Expand Up @@ -458,7 +457,7 @@ def install_webdriver(self, dest=None, channel=None):
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:
Expand Down Expand Up @@ -497,7 +496,7 @@ def install_webdriver(self, dest=None, channel=None):
chrome = Chrome()
return chrome.install_webdriver(dest, channel)

def version(self, binary):
def version(self, binary=None, webdriver_binary=None):
return None

class Opera(Browser):
Expand Down Expand Up @@ -562,7 +561,7 @@ def install_webdriver(self, dest=None, channel=None):
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:
Expand Down Expand Up @@ -593,7 +592,7 @@ def find_webdriver(self, channel=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
def version(self, binary=None, webdriver_binary=None):
return None


Expand All @@ -619,7 +618,7 @@ def find_webdriver(self, channel=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
def version(self, binary=None, webdriver_binary=None):
return None


Expand Down Expand Up @@ -647,10 +646,21 @@ def find_webdriver(self, channel=None):
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 not None:
try:
output = call(webdriver_binary, "--version").strip()
# TODO: explain
if output.startswith('Included with '):
output = output[14:]
return output
except subprocess.CalledProcessError:
# TODO stderr gets printed :'(
pass
# TODO: this message doesn't show up anywhere
logger.warn("Unable to determine Safari version.")
return None


class SafariWebDriver(Safari):
product = "safari_webdriver"

Expand Down Expand Up @@ -707,7 +717,7 @@ def find_webdriver(self, channel=None):
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())
Expand Down Expand Up @@ -737,7 +747,7 @@ def find_webdriver(self, channel=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
def version(self, binary=None, webdriver_binary=None):
return None


Expand All @@ -759,5 +769,5 @@ def find_webdriver(self, channel=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
def version(self, binary=None, webdriver_binary=None):
return None
3 changes: 2 additions & 1 deletion tools/wpt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,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


Expand Down

0 comments on commit a35a216

Please sign in to comment.