Bug 1564425 - Improve error handling of mach addtest, r=bgrins

Ensure that if we try to create a mochitest of unsupported file type we return a
useful error

Differential Revision: https://phabricator.services.mozilla.com/D38224

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Graham 2019-08-26 21:06:02 +00:00
parent 5dbd99f0b6
commit 92fb46bfa6
2 changed files with 10 additions and 0 deletions

View File

@ -70,12 +70,15 @@ class MochitestCreator(Creator):
template_file_name = self.templates.get(self.suite)
if template_file_name is None:
print("Sorry, `addtest` doesn't currently know how to add {}".format(self.suite))
return None
template_file_name = template_file_name % {"doc": self.doc}
template_file = os.path.join(mochitest_templates, template_file_name)
if not os.path.isfile(template_file):
print("Sorry, `addtest` doesn't currently know how to add {} with document type {}"
.format(self.suite, self.doc))
return None
with open(template_file) as f:

View File

@ -193,7 +193,11 @@ class AddTest(MachCommandBase):
creator.check_args()
paths = []
added_tests = False
for path, template in creator:
if not template:
continue
added_tests = True
if (path):
paths.append(path)
print("Adding a test file at {} (suite `{}`)".format(path, suite))
@ -209,6 +213,9 @@ class AddTest(MachCommandBase):
# write to stdout if you passed only suite and doc and not a file path
print(template)
if not added_tests:
return 1
if test:
creator.update_manifest()