Commit 043d5563 authored by hzl's avatar hzl Committed by Commit bot

Dump empty json to output when no shard json file is given.

Previously when test results presentation does not receive any json
input file, the script will raise a parser error. This is confusing to
developer, because they may mistake the parser error in this script as
the cause of the crash, instead of the reason why no json input file is
given at the first place.

In this cl, test results presentation will not raise error anymore when
no json file is given.

BUG=715972

Review-Url: https://codereview.chromium.org/2845973004
Cr-Commit-Position: refs/heads/master@{#467834}
parent b539fa11
...@@ -306,6 +306,7 @@ def upload_to_google_bucket(html, test_name, builder_name, build_number, ...@@ -306,6 +306,7 @@ def upload_to_google_bucket(html, test_name, builder_name, build_number,
return '%s/%s/%s' % (server_url, bucket, dest) return '%s/%s/%s' % (server_url, bucket, dest)
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--json-file', help='Path of json file.') parser.add_argument('--json-file', help='Path of json file.')
...@@ -347,16 +348,21 @@ def main(): ...@@ -347,16 +348,21 @@ def main():
if ((args.build_properties is None) == if ((args.build_properties is None) ==
(args.build_number is None or args.builder_name is None)): (args.build_number is None or args.builder_name is None)):
raise parser.error('Exactly one of build_perperties or ' raise parser.error('Exactly one of build_perperties or '
'(build_number or builder_names) should be given.') '(build_number or builder_name) should be given.')
if (args.build_number is None) != (args.builder_name is None): if (args.build_number is None) != (args.builder_name is None):
raise parser.error('args.build_number and args.builder_name ' raise parser.error('args.build_number and args.builder_name '
'has to be be given together' 'has to be be given together'
'or not given at all.') 'or not given at all.')
if (len(args.positional) == 0) == (args.json_file is None): if len(args.positional) == 0 and args.json_file is None:
if args.output_json:
with open(args.output_json, 'w') as f:
json.dump({}, f)
return
elif len(args.positional) != 0 and args.json_file:
raise parser.error('Exactly one of args.positional and ' raise parser.error('Exactly one of args.positional and '
'args.json_file should be given.') 'args.json_file should be given.')
if args.build_properties: if args.build_properties:
build_properties = json.loads(args.build_properties) build_properties = json.loads(args.build_properties)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment