Skip to content

Commit

Permalink
Bug 1442708 [wpt PR 9748] - Firefox browser install now uses mozdownl…
Browse files Browse the repository at this point in the history
…oad and mozinstall, a=testonly

Automatic update from web-platform-testsFirefox browser install now uses mozdownload and mozinstall (#9748)

Use mozinstall to install firefox into the virtualenv. This should work in a cross-platform way and reduce the amount of custom code we have to maintain.

wpt-commits: c7c6f86d31f81bf6be181ae69b5556991c615021
wpt-pr: 9748
wpt-commits: c7c6f86d31f81bf6be181ae69b5556991c615021
wpt-pr: 9748
  • Loading branch information
Cactusmachete authored and jgraham committed Mar 31, 2018
1 parent 2cc0e9b commit 4906276
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 39 deletions.
45 changes: 20 additions & 25 deletions testing/web-platform/tests/tools/wpt/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from io import BytesIO

from utils import call, get, untar, unzip
from mozdownload import FactoryScraper
import mozinstall

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -105,36 +107,29 @@ def platform_string_geckodriver(self):

return "%s%s" % (platform, bits)

def latest_nightly_listing(self):
resp = get("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/")
resp.raise_for_status()
return resp.text

def get_nightly_link(self, index, platform):
pattern = re.compile("<a[^>]*>(firefox-(\d+)\.\d(?:\w\d)?.en-US.%s\.tar\.bz2)" % platform)
max_version = None
for match in pattern.finditer(index):
try:
version = int(match.group(2))
except ValueError:
continue
if max_version is None or version > max_version[0]:
max_version = (version, match.group(1))
if not max_version:
raise ValueError("Failed to find version to download")
return ("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/%s" %
max_version[1])

def install(self, dest=None):
"""Install Firefox."""

if dest is None:
dest = os.getcwd()

nightly_link = self.get_nightly_link(self.latest_nightly_listing(),
self.platform_string())
resp = get(nightly_link)
resp.raise_for_status()
untar(resp.raw, dest=dest)
filename = FactoryScraper('daily', branch='mozilla-central', destination=dest).download()

try:
mozinstall.install(filename, dest)
except mozinstall.mozinstall.InstallError as e:
if uname[0] == "Darwin":
# mozinstall will fail here if nightly is already installed in the venv
# This only occurs on macOS because shutil.copy_tree() is called in
# mozinstall._install_dmg and will fail if the file already exists.
# copytree isn't used while installing on Windows/linux, so the same error
# won't be thrown if we try to rewrite there.
mozinstall.uninstall(dest+'/Firefox Nightly.app')
mozinstall.install(filename, dest)
else:
raise

os.remove(filename)
return find_executable("firefox", os.path.join(dest, "firefox"))

def find_binary(self):
Expand Down
2 changes: 1 addition & 1 deletion testing/web-platform/tests/tools/wpt/commands.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"run": {"path": "run.py", "script": "run", "parser": "create_parser", "help": "Run tests in a browser",
"virtualenv": true, "install": ["requests"], "requirements": ["../wptrunner/requirements.txt"]},
"virtualenv": true, "install": ["requests", "mozinstall", "mozdownload"], "requirements": ["../wptrunner/requirements.txt"]},
"update-expectations": {"path": "update.py", "script": "update_expectations",
"parser": "create_parser_update", "help": "Update expectations files from raw logs.",
"virtualenv": true, "install": ["requests"],
Expand Down
13 changes: 0 additions & 13 deletions testing/web-platform/tests/tools/wpt/tests/test_browser.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ mozprocess == 0.26
mozcrash == 1.0
mozrunner == 6.14
mozleak == 0.1
mozinstall == 1.15
mozdownload == 1.23

0 comments on commit 4906276

Please sign in to comment.