mirror of
https://github.com/servo/servo.git
synced 2025-06-10 09:33:13 +00:00
mach filter-intermittents: add progress and --json output mode
This commit is contained in:
parent
9a03911abf
commit
ab578bc4cf
1 changed files with 17 additions and 3 deletions
|
@ -529,6 +529,8 @@ class MachCommands(CommandBase):
|
||||||
help='Print filtered log to file')
|
help='Print filtered log to file')
|
||||||
@CommandArgument('--log-intermittents', default=None,
|
@CommandArgument('--log-intermittents', default=None,
|
||||||
help='Print intermittents to file')
|
help='Print intermittents to file')
|
||||||
|
@CommandArgument('--json', dest="json_mode", default=False, action="store_true",
|
||||||
|
help='Output filtered and intermittents as JSON')
|
||||||
@CommandArgument('--auth', default=None,
|
@CommandArgument('--auth', default=None,
|
||||||
help='File containing basic authorization credentials for Github API (format `username:password`)')
|
help='File containing basic authorization credentials for Github API (format `username:password`)')
|
||||||
@CommandArgument('--tracker-api', default=None, action='store',
|
@CommandArgument('--tracker-api', default=None, action='store',
|
||||||
|
@ -539,6 +541,7 @@ class MachCommands(CommandBase):
|
||||||
summary,
|
summary,
|
||||||
log_filteredsummary,
|
log_filteredsummary,
|
||||||
log_intermittents,
|
log_intermittents,
|
||||||
|
json_mode,
|
||||||
auth,
|
auth,
|
||||||
tracker_api,
|
tracker_api,
|
||||||
reporter_api):
|
reporter_api):
|
||||||
|
@ -551,6 +554,7 @@ class MachCommands(CommandBase):
|
||||||
failures = [json.loads(line) for line in file]
|
failures = [json.loads(line) for line in file]
|
||||||
actual_failures = []
|
actual_failures = []
|
||||||
intermittents = []
|
intermittents = []
|
||||||
|
progress = 0
|
||||||
for failure in failures:
|
for failure in failures:
|
||||||
if tracker_api:
|
if tracker_api:
|
||||||
if tracker_api == 'default':
|
if tracker_api == 'default':
|
||||||
|
@ -576,21 +580,31 @@ class MachCommands(CommandBase):
|
||||||
data = json.load(search)
|
data = json.load(search)
|
||||||
is_intermittent = data['total_count'] > 0
|
is_intermittent = data['total_count'] > 0
|
||||||
|
|
||||||
|
progress += 1
|
||||||
|
print(f" [{progress}/{len(failures)}]", file=sys.stderr, end="\r")
|
||||||
|
|
||||||
if is_intermittent:
|
if is_intermittent:
|
||||||
if 'output' in failure:
|
if json_mode:
|
||||||
|
intermittents.append(failure)
|
||||||
|
elif 'output' in failure:
|
||||||
intermittents.append(failure["output"])
|
intermittents.append(failure["output"])
|
||||||
else:
|
else:
|
||||||
intermittents.append("%s [expected %s] %s \n"
|
intermittents.append("%s [expected %s] %s \n"
|
||||||
% (failure["status"], failure["expected"], failure['test']))
|
% (failure["status"], failure["expected"], failure['test']))
|
||||||
else:
|
else:
|
||||||
if 'output' in failure:
|
if json_mode:
|
||||||
|
actual_failures.append(failure)
|
||||||
|
elif 'output' in failure:
|
||||||
actual_failures.append(failure["output"])
|
actual_failures.append(failure["output"])
|
||||||
else:
|
else:
|
||||||
actual_failures.append("%s [expected %s] %s \n"
|
actual_failures.append("%s [expected %s] %s \n"
|
||||||
% (failure["status"], failure["expected"], failure['test']))
|
% (failure["status"], failure["expected"], failure['test']))
|
||||||
|
|
||||||
def format(outputs, description, file=sys.stdout):
|
def format(outputs, description, file=sys.stdout):
|
||||||
formatted = "%s %s:\n%s" % (len(outputs), description, "\n".join(outputs))
|
if json_mode:
|
||||||
|
formatted = json.dumps(outputs)
|
||||||
|
else:
|
||||||
|
formatted = "%s %s:\n%s" % (len(outputs), description, "\n".join(outputs))
|
||||||
if file == sys.stdout:
|
if file == sys.stdout:
|
||||||
file.write(formatted)
|
file.write(formatted)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue