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
--- 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