Bug 1369109 - Add --rebuild option to mach wpt-manifest-update, r=majazf draft
authorJames Graham <james@hoppipolla.co.uk>
Mon, 05 Jun 2017 16:39:45 +0100
changeset 589082 06b4bc4b6aa3f99b2532166d32c9e83101d4601f
parent 589054 b7dfffc23174d96c9f85ce362f96c3751be7d113
child 589083 f4105c740afb30f3b29bdaedfa9955849edaaa7a
push id62243
push userbmo:james@hoppipolla.co.uk
push dateMon, 05 Jun 2017 15:42:17 +0000
reviewersmajazf
bugs1369109
milestone55.0a1
Bug 1369109 - Add --rebuild option to mach wpt-manifest-update, r=majazf This is required for cases where files have not changed but the manifest logic has changed. MozReview-Commit-ID: E46HtouILS2
testing/web-platform/mach_commands.py
testing/web-platform/manifestupdate.py
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -283,22 +283,22 @@ testing/web-platform/tests for tests tha
             wpt_kwargs = vars(p.parse_args(["--manifest-update", path]))
             context.commands.dispatch("web-platform-tests", context, **wpt_kwargs)
 
         if proc:
             proc.wait()
 
 
 class WPTManifestUpdater(MozbuildObject):
-    def run_update(self, check_clean=False, **kwargs):
+    def run_update(self, check_clean=False, rebuild=False, **kwargs):
         import manifestupdate
         from wptrunner import wptlogging
         logger = wptlogging.setup(kwargs, {"mach": sys.stdout})
         wpt_dir = os.path.abspath(os.path.join(self.topsrcdir, 'testing', 'web-platform'))
-        manifestupdate.update(logger, wpt_dir, check_clean)
+        manifestupdate.update(logger, wpt_dir, check_clean, rebuild)
 
 
 def create_parser_wpt():
     from wptrunner import wptcommandline
     return wptcommandline.create_parser(["firefox", "chrome", "edge", "servo"])
 
 def create_parser_update():
     from update import updatecommandline
--- a/testing/web-platform/manifestupdate.py
+++ b/testing/web-platform/manifestupdate.py
@@ -13,44 +13,49 @@ def do_delayed_imports(wpt_dir):
     global manifest
     sys.path.insert(0, os.path.join(wpt_dir, "tools", "manifest"))
     import manifest
 
 def create_parser():
     p = argparse.ArgumentParser()
     p.add_argument("--check-clean", action="store_true",
                    help="Check that updating the manifest doesn't lead to any changes")
+    p.add_argument("--rebuild", action="store_true",
+                   help="Rebuild the manifest from scratch")
     commandline.add_logging_group(p)
 
     return p
 
 
-def update(logger, wpt_dir, check_clean=True):
+def update(logger, wpt_dir, check_clean=True, rebuild=False):
     localpaths = imp.load_source("localpaths",
                                  os.path.join(wpt_dir, "tests", "tools", "localpaths.py"))
     kwargs = {"config": os.path.join(wpt_dir, "wptrunner.ini"),
               "tests_root": None,
               "metadata_root": None}
 
     set_from_config(kwargs)
     config = kwargs["config"]
     test_paths = get_test_paths(config)
 
     do_delayed_imports(wpt_dir)
 
     if check_clean:
         return _check_clean(logger, test_paths)
 
-    return _update(logger, test_paths)
+    return _update(logger, test_paths, rebuild)
 
 
-def _update(logger, test_paths):
+def _update(logger, test_paths, rebuild):
     for url_base, paths in test_paths.iteritems():
         manifest_path = os.path.join(paths["metadata_path"], "MANIFEST.json")
-        m = manifest.manifest.load(paths["tests_path"], manifest_path)
+        if rebuild:
+            m = manifest.manifest.Manifest(url_base)
+        else:
+            m = manifest.manifest.load(paths["tests_path"], manifest_path)
         manifest.update.update(paths["tests_path"], m, working_copy=True)
         manifest.manifest.write(m, manifest_path)
     return 0
 
 
 def _check_clean(logger, test_paths):
     manifests_by_path = {}
     rv = 0