Bug 1441492 [wpt PR 9687] - This adds the ability to download latest Servo for `wpt run`, a=testonly
authorrohilla21 <kritirohilla567@gmail.com>
Mon, 09 Apr 2018 16:31:35 +0000
changeset 467008 1e0357b5ad237d0c191f80d5fee6c207d170a4cb
parent 467007 3582e94198299a6c64414d17a79d9b6343fd1849
child 467009 efe7fae9f43f1c2ad25842b0cdf73ae75eccebba
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1441492
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1441492 [wpt PR 9687] - This adds the ability to download latest Servo for `wpt run`, a=testonly Automatic update from web-platform-testsThis adds the ability to download latest Servo for `wpt run` Closes https://github.com/w3c/web-platform-tests/issues/9544 wpt-commits: 2f110a48f5fe1f4f94840003aaf5546e0c3fea25 wpt-pr: 9687 wpt-commits: 2f110a48f5fe1f4f94840003aaf5546e0c3fea25 wpt-pr: 9687
testing/web-platform/tests/tools/wpt/browser.py
testing/web-platform/tests/tools/wpt/run.py
--- a/testing/web-platform/tests/tools/wpt/browser.py
+++ b/testing/web-platform/tests/tools/wpt/browser.py
@@ -439,30 +439,61 @@ class Safari(Browser):
 
 
 class Servo(Browser):
     """Servo-specific interface."""
 
     product = "servo"
     requirements = "requirements_servo.txt"
 
+    def platform_components(self):
+        platform = {
+            "Linux": "linux",
+            "Windows": "win",
+            "Darwin": "mac"
+        }.get(uname[0])
+
+        if platform is None:
+            raise ValueError("Unable to construct a valid Servo package for current platform")
+
+        if platform == "linux":
+            extension = ".tar.gz"
+            decompress = untar
+        elif platform == "win" or platform == "mac":
+            raise ValueError("Unable to construct a valid Servo package for current platform")
+
+        return (platform, extension, decompress)
+
     def install(self, dest=None):
-        raise NotImplementedError
+        """Install latest Browser Engine."""
+        if dest is None:
+            dest = os.pwd
+
+        platform, extension, decompress = self.platform_components()
+        url = "https://download.servo.org/nightly/%s/servo-latest%s" % (platform, extension)
+
+        decompress(get(url).raw, dest=dest)
+        path = find_executable("servo", os.path.join(dest, "servo"))
+        st = os.stat(path)
+        os.chmod(path, st.st_mode | stat.S_IEXEC)
+        return path
 
     def find_binary(self):
         return find_executable("servo")
 
     def find_webdriver(self):
         return None
 
     def install_webdriver(self, dest=None):
         raise NotImplementedError
 
     def version(self, root):
-        return None
+        """Retrieve the release version of the installed browser."""
+        output = call(self.binary, "--version")
+        return re.search(r"[0-9\.]+( [a-z]+)?$", output.strip()).group(0)
 
 
 class Sauce(Browser):
     """Sauce-specific interface."""
 
     product = "sauce"
     requirements = "requirements_sauce.txt"
 
--- a/testing/web-platform/tests/tools/wpt/run.py
+++ b/testing/web-platform/tests/tools/wpt/run.py
@@ -347,17 +347,18 @@ class Sauce(BrowserSetup):
         kwargs["test_types"] = ["testharness", "reftest"]
 
 
 class Servo(BrowserSetup):
     name = "servo"
     browser_cls = browser.Servo
 
     def install(self, venv):
-        raise NotImplementedError
+        if self.prompt_install(self.name):
+            return self.browser.install(venv.path)
 
     def setup_kwargs(self, kwargs):
         if kwargs["binary"] is None:
             binary = self.browser.find_binary()
 
             if binary is None:
                 raise WptrunError("Unable to find servo binary on the PATH")
             kwargs["binary"] = binary