mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
mach: Fail on invalid argument in try_parser (#38324)
This will block the command, print an error message about an invalid argument being passed to the ./mach try command, and return the exit code. Testing: `./mach try test-wpt` Fixes: #38193 Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This commit is contained in:
parent
554b2da1ad
commit
239bdd7c1a
2 changed files with 10 additions and 1 deletions
|
@ -808,7 +808,11 @@ class MachCommands(CommandBase):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try_string = " ".join(try_strings)
|
try_string = " ".join(try_strings)
|
||||||
config = servo.try_parser.Config(try_string)
|
try:
|
||||||
|
config = servo.try_parser.Config(try_string)
|
||||||
|
except ValueError as err:
|
||||||
|
print(f"Failed to parse `try` config because of {err}")
|
||||||
|
return 1
|
||||||
print(f"Trying on {remote} ({remote_url}) with following configuration:")
|
print(f"Trying on {remote} ({remote_url}) with following configuration:")
|
||||||
print()
|
print()
|
||||||
print(textwrap.indent(config.to_json(indent=2), prefix=" "))
|
print(textwrap.indent(config.to_json(indent=2), prefix=" "))
|
||||||
|
|
|
@ -197,6 +197,7 @@ class Config(object):
|
||||||
input = "full"
|
input = "full"
|
||||||
|
|
||||||
words: list[str] = input.split(" ")
|
words: list[str] = input.split(" ")
|
||||||
|
invalid_words: list[str] = list()
|
||||||
|
|
||||||
for word in words:
|
for word in words:
|
||||||
# Handle keywords.
|
# Handle keywords.
|
||||||
|
@ -220,10 +221,14 @@ class Config(object):
|
||||||
job = handle_preset(word)
|
job = handle_preset(word)
|
||||||
job = handle_modifier(job, word)
|
job = handle_modifier(job, word)
|
||||||
if job is None:
|
if job is None:
|
||||||
|
invalid_words.append(word)
|
||||||
print(f"Ignoring unknown preset {word}")
|
print(f"Ignoring unknown preset {word}")
|
||||||
else:
|
else:
|
||||||
self.add_or_merge_job_to_matrix(job)
|
self.add_or_merge_job_to_matrix(job)
|
||||||
|
|
||||||
|
if len(invalid_words) > 0:
|
||||||
|
raise ValueError(f"Invalid `try` argument: {', '.join(invalid_words)}")
|
||||||
|
|
||||||
def add_or_merge_job_to_matrix(self, job: JobConfig) -> None:
|
def add_or_merge_job_to_matrix(self, job: JobConfig) -> None:
|
||||||
for existing_job in self.matrix:
|
for existing_job in self.matrix:
|
||||||
if existing_job.merge(job):
|
if existing_job.merge(job):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue