Bug 1377886 - Improve handling of reftests in mach wpt-create, r=AutomatedTester draft
authorJames Graham <james@hoppipolla.co.uk>
Mon, 03 Jul 2017 15:39:20 +0100
changeset 603290 0f033fc2433ef563f0ffc0241e8ded4df9c09e2b
parent 603289 5d3b94c798cf219477154ce145ffe99862a538e6
child 635871 3c240f235200012e7580e32c347cf9b1151789bf
push id66724
push userbmo:james@hoppipolla.co.uk
push dateMon, 03 Jul 2017 14:41:45 +0000
reviewersAutomatedTester
bugs1377886
milestone56.0a1
Bug 1377886 - Improve handling of reftests in mach wpt-create, r=AutomatedTester Create an emmpty reference file if one doesn't exist, and open it in the editor. MozReview-Commit-ID: 5aBLp2AdnzY
testing/web-platform/mach_commands.py
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -261,29 +261,36 @@ testing/web-platform/tests for tests tha
             template += self.template_body_th
         try:
             os.makedirs(os.path.dirname(path))
         except OSError:
             pass
         with open(path, "w") as f:
             f.write(template)
 
+        ref_path = kwargs["ref"]
+        if ref_path and not os.path.exists(ref_path):
+            with open(ref_path, "w") as f:
+                f.write(self.template_prefix % {"documentElement": ""})
+
         if kwargs["no_editor"]:
             editor = None
         elif kwargs["editor"]:
             editor = kwargs["editor"]
         elif "VISUAL" in os.environ:
             editor = os.environ["VISUAL"]
         elif "EDITOR" in os.environ:
             editor = os.environ["EDITOR"]
         else:
             editor = None
 
         proc = None
         if editor:
+            if ref_path:
+                path = "%s %s" % (path, ref_path)
             proc = subprocess.Popen("%s %s" % (editor, path), shell=True)
 
         if proc:
             proc.wait()
 
         context.commands.dispatch("wpt-manifest-update", context, {"check_clean": False, "rebuild": False})
 
 
@@ -311,17 +318,17 @@ def create_parser_create():
                    help="Don't try to open the test in an editor")
     p.add_argument("-e", "--editor", action="store", help="Editor to use")
     p.add_argument("--long-timeout", action="store_true",
                    help="Test should be given a long timeout (typically 60s rather than 10s, but varies depending on environment)")
     p.add_argument("--overwrite", action="store_true",
                    help="Allow overwriting an existing test file")
     p.add_argument("-r", "--reftest", action="store_true",
                    help="Create a reftest rather than a testharness (js) test"),
-    p.add_argument("-ref", "--reference", dest="ref", help="Path to the reference file")
+    p.add_argument("-m", "--reference", dest="ref", help="Path to the reference file")
     p.add_argument("--mismatch", action="store_true",
                    help="Create a mismatch reftest")
     p.add_argument("--wait", action="store_true",
                    help="Create a reftest that waits until takeScreenshot() is called")
     p.add_argument("path", action="store", help="Path to the test file")
     return p