Bug 1446374 - Add a `mach wpt-serve` command, r=ato draft
authorJames Graham <james@hoppipolla.co.uk>
Fri, 16 Mar 2018 13:35:41 +0000
changeset 769291 dced14b754e7cdccd4f0e94f4d6729ff9420ddce
parent 769290 9036d6ea683792d84833f82bc8e74deed880a5de
push id103092
push userbmo:james@hoppipolla.co.uk
push dateMon, 19 Mar 2018 10:50:07 +0000
reviewersato
bugs1446374
milestone61.0a1
Bug 1446374 - Add a `mach wpt-serve` command, r=ato This start the web-platform-tests server locally but doesn't run any tests. MozReview-Commit-ID: K94zW4GXzBu
testing/web-platform/mach_commands.py
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -320,16 +320,21 @@ def create_parser_create():
     return p
 
 
 def create_parser_manifest_update():
     import manifestupdate
     return manifestupdate.create_parser()
 
 
+def create_parser_serve():
+    from serve import serve
+    return serve.get_parser()
+
+
 @CommandProvider
 class MachCommands(MachCommandBase):
     def setup(self):
         self._activate_virtualenv()
 
     @Command("web-platform-tests",
              category="testing",
              conditions=[conditions.is_firefox],
@@ -401,8 +406,22 @@ class MachCommands(MachCommandBase):
 
     @Command("wpt-manifest-update",
              category="testing",
              parser=create_parser_manifest_update)
     def wpt_manifest_update(self, **params):
         self.setup()
         wpt_manifest_updater = self._spawn(WPTManifestUpdater)
         return wpt_manifest_updater.run_update(**params)
+
+    @Command("wpt-serve",
+             category="testing",
+             parser=create_parser_serve)
+    def serve(self, **params):
+        import logging
+        from serve import serve
+        root_logger = logging.getLogger()
+        handler = logging.StreamHandler(sys.stderr)
+        formatter = logging.Formatter(logging.BASIC_FORMAT)
+        handler.setFormatter(formatter)
+        root_logger.addHandler(handler)
+        root_logger.setLevel(logging.DEBUG)
+        serve.run(**params)