Skip to content

Commit

Permalink
Install nightly geckodriver when testing Firefox nightly.
Browse files Browse the repository at this point in the history
This (ab)uses mozdownload to grab the common.tests.tar.gz package from the
latest nightly build and extracts geckodriver from that. The main disadvantage
is that it's rather slow since the package itself is rather large and we want
only a small part of it. The solution to this would be to package up
geckodriver by itself on taskcluster, but that will require changes in the
gecko buildsystem.
  • Loading branch information
jgraham committed Sep 5, 2018
1 parent e57909d commit 480fd85
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 19 deletions.
59 changes: 46 additions & 13 deletions tools/wpt/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def install(self, dest=None):
return NotImplemented

@abstractmethod
def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
"""Install the WebDriver implementation for this browser."""
return NotImplemented

Expand Down Expand Up @@ -299,11 +299,18 @@ def _latest_geckodriver_version(self):
assert latest_release != 0
return "v%s.%s.%s" % tuple(str(item) for item in latest_release)

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
"""Install latest Geckodriver."""
if dest is None:
dest = os.getcwd()

if channel == "nightly":
path = self.install_geckodriver_nightly(dest)
if path is not None:
return path
else:
logger.warning("Nightly webdriver not found; falling back to release")

version = self._latest_geckodriver_version()
format = "zip" if uname[0] == "Windows" else "tar.gz"
logger.debug("Latest geckodriver release %s" % version)
Expand All @@ -315,6 +322,32 @@ def install_webdriver(self, dest=None):
untar(get(url).raw, dest=dest)
return find_executable(os.path.join(dest, "geckodriver"))

def install_geckodriver_nightly(self, dest):
import tarfile
import mozdownload
logger.info("Attempting to install webdriver from nightly")
try:
s = mozdownload.DailyScraper(branch="mozilla-central",
extension="common.tests.tar.gz",
destination=dest)
package_path = s.download()
except mozdownload.errors.NotFoundError:
return
exe_suffix = ".exe" if uname[0] == "Windows" else ""
with tarfile.open(package_path, "r") as f:
try:
member = f.getmember("bin%sgeckodriver%s" % (os.path.sep,
exe_suffix))
except KeyError:
return
# Remove bin/ from the path.
member.name = os.path.basename(member.name)
f.extractall(members=[member], path=dest)
path = os.path.join(dest, member.name)
logger.info("Extracted geckodriver to %s" % path)
os.unlink(package_path)
return path

def version(self, binary=None, channel=None):
"""Retrieve the release version of the installed browser."""
binary = binary or self.find_binary(channel)
Expand All @@ -340,7 +373,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
raise NotImplementedError

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary=None):
Expand Down Expand Up @@ -394,7 +427,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return find_executable("chromedriver")

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
if dest is None:
dest = os.pwd
latest = get("http://chromedriver.storage.googleapis.com/LATEST_RELEASE").text.strip()
Expand Down Expand Up @@ -442,9 +475,9 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return find_executable("chromedriver")

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
chrome = Chrome()
return chrome.install_webdriver(dest)
return chrome.install_webdriver(dest, channel)

def version(self, binary):
return None
Expand Down Expand Up @@ -495,7 +528,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return find_executable("operadriver")

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
if dest is None:
dest = os.pwd
latest = get("https://api.github.com/repos/operasoftware/operachromiumdriver/releases/latest").json()["tag_name"]
Expand Down Expand Up @@ -538,7 +571,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return find_executable("MicrosoftWebDriver")

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
Expand All @@ -560,7 +593,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return find_executable("IEDriverServer.exe")

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
Expand All @@ -585,7 +618,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return find_executable("safaridriver")

def install_webdriver(self):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
Expand Down Expand Up @@ -641,7 +674,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return None

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
Expand All @@ -665,7 +698,7 @@ def find_binary(self, venev_path=None, channel=None):
def find_webdriver(self):
raise NotImplementedError

def install_webdriver(self, dest=None):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
Expand All @@ -687,7 +720,7 @@ def find_binary(self, venv_path=None, channel=None):
def find_webdriver(self):
return None

def install_webdriver(self):
def install_webdriver(self, dest=None, channel=None):
raise NotImplementedError

def version(self, binary):
Expand Down
9 changes: 4 additions & 5 deletions tools/wpt/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def get_parser():
default="nightly", help='Name of browser release channel. '
'"stable" and "release" are synonyms for the latest browser stable release,'
'"nightly", "dev", "experimental", and "preview" are all synonyms for '
'the latest available development release.')
'the latest available development release. For WebDriver installs, '
'we attempt to select an appropriate, compatible, version for the '
'latest browser release on the selected channel.')
parser.add_argument('-d', '--destination',
help='filesystem directory to place the component')
return parser
Expand Down Expand Up @@ -78,9 +80,6 @@ def install(name, component, destination, channel="nightly"):

subclass = getattr(browser, name.title())
sys.stdout.write('Now installing %s %s...\n' % (name, component))
kwargs = {"dest": destination}
if component == "browser":
kwargs["channel"] = channel
path = getattr(subclass(), method)(**kwargs)
path = getattr(subclass(), method)(dest=destination, channel=channel)
if path:
sys.stdout.write('Binary installed as %s\n' % (path,))
4 changes: 3 additions & 1 deletion tools/wpt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def create_parser():
default=None, help='Name of browser release channel.'
'"stable" and "release" are synonyms for the latest browser stable release,'
'"nightly", "dev", "experimental", and "preview" are all synonyms for '
'the latest available development release.')
'the latest available development release. For WebDriver installs, '
'we attempt to select an appropriate, compatible, version for the '
'latest browser release on the selected channel.')
parser._add_container_actions(wptcommandline.create_parser())
return parser

Expand Down

0 comments on commit 480fd85

Please sign in to comment.