mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #29222 - delan:mach-filter-intermittents-json, r=cybai
mach filter-intermittents: add progress and --json output mode filter-intermittents takes a while, because it needs to look up each failure against the tracker api (or GitHub api), so it would be nice to know how long we’ll need to wait when running it interactively. The output is also pretty-printed in a format that’s not the easiest to analyse. This patch adds some progress output (on stderr, one line with \\r), plus a --json output format as follows: [{"test": "/path/to/foo", "output": "..."}, {"test": "/path/to/bar", "output": "..."}, ...] --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] ~~`./mach build -d` does not report any errors~~ - [ ] ~~`./mach test-tidy` does not report any errors~~ - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because they affect mach filter-intermittents only
This commit is contained in:
commit
ce92b7bfbd
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