Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: build/android/pylib/results/presentation/test_results_presentation.py

Issue 2821533005: Make test results presentation enabled for swarming. (Closed)
Patch Set: fix john's comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | testing/buildbot/chromium.linux.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 # 2 #
3 # Copyright 2017 The Chromium Authors. All rights reserved. 3 # Copyright 2017 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import argparse 7 import argparse
8 import collections 8 import collections
9 import json 9 import json
10 import tempfile 10 import tempfile
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 gsutil_path = os.path.join(BASE_DIR, 'third_party', 'catapult', 301 gsutil_path = os.path.join(BASE_DIR, 'third_party', 'catapult',
302 'third_party', 'gsutil', 'gsutil.py') 302 'third_party', 'gsutil', 'gsutil.py')
303 subprocess.check_call([ 303 subprocess.check_call([
304 sys.executable, gsutil_path, '-h', "Content-Type:%s" % content_type, 304 sys.executable, gsutil_path, '-h', "Content-Type:%s" % content_type,
305 'cp', temp_file.name, 'gs://%s/%s' % (bucket, dest)]) 305 'cp', temp_file.name, 'gs://%s/%s' % (bucket, dest)])
306 306
307 return '%s/%s/%s' % (server_url, bucket, dest) 307 return '%s/%s/%s' % (server_url, bucket, dest)
308 308
309 def main(): 309 def main():
310 parser = argparse.ArgumentParser() 310 parser = argparse.ArgumentParser()
311 parser.add_argument('--json-file', help='Path of json file.', required=True) 311 parser.add_argument('--json-file', help='Path of json file.')
312 parser.add_argument('--cs-base-url', help='Base url for code search.', 312 parser.add_argument('--cs-base-url', help='Base url for code search.',
313 default='http://cs.chromium.org') 313 default='http://cs.chromium.org')
314 parser.add_argument('--bucket', help='Google storage bucket.', required=True) 314 parser.add_argument('--bucket', help='Google storage bucket.', required=True)
315 parser.add_argument('--builder-name', help='Builder name.', required=True) 315 parser.add_argument('--builder-name', help='Builder name.')
316 parser.add_argument('--build-number', help='Build number.', required=True) 316 parser.add_argument('--build-number', help='Build number.')
317 parser.add_argument('--test-name', help='The name of the test.', 317 parser.add_argument('--test-name', help='The name of the test.',
318 required=True) 318 required=True)
319 parser.add_argument('--server-url', help='The url of the server.', 319 parser.add_argument('--server-url', help='The url of the server.',
320 default='https://storage.cloud.google.com') 320 default='https://storage.cloud.google.com')
321 parser.add_argument( 321 parser.add_argument(
322 '--content-type', 322 '--content-type',
323 help=('Content type, which is used to determine ' 323 help=('Content type, which is used to determine '
324 'whether to download the file, or view in browser.'), 324 'whether to download the file, or view in browser.'),
325 default='text/html', 325 default='text/html',
326 choices=['text/html', 'application/octet-stream']) 326 choices=['text/html', 'application/octet-stream'])
327 parser.add_argument(
328 '-o', '--output-json',
329 help='(Swarming Merge Script API)'
330 ' Output JSON file to create.')
331 parser.add_argument(
332 '--build-properties',
333 help='(Swarming Merge Script API) '
334 'Build property JSON file provided by recipes.')
335 parser.add_argument(
336 '--summary-json',
337 help='(Swarming Merge Script API)'
338 ' Summary of shard state running on swarming.'
339 ' (Output of the swarming.py collect'
340 ' --task-summary-json=XXX command.)')
341 parser.add_argument(
342 'positional', nargs='*',
343 help='output.json from shards.')
344
327 345
328 args = parser.parse_args() 346 args = parser.parse_args()
329 if os.path.exists(args.json_file): 347
330 result_html_string = result_details(args.json_file, args.cs_base_url, 348 if args.build_properties:
jbudorick 2017/04/17 20:40:04 As written, your argument logic makes a lot of unc
BigBossZhiling 2017/04/17 21:56:11 Done.
349 build_properties = json.loads(args.build_properties)
350 build_number = build_properties['buildnumber']
351 builder_name = build_properties['buildname']
352 else:
353 build_number = args.build_number
354 builder_name = args.builder_name
355
356 if args.output_json:
jbudorick 2017/04/17 20:40:04 Given how you're using args.output_json/output_jso
BigBossZhiling 2017/04/17 21:56:11 Done.
357 output_json = args.output_json
358
359 if args.positional:
jbudorick 2017/04/17 20:40:04 Here, we're expecting either json_file or position
BigBossZhiling 2017/04/17 21:56:11 Done.
360 json_file = args.positional[0]
361 else:
362 json_file = args.json_file
363
364
365 if os.path.exists(json_file):
jbudorick 2017/04/17 20:40:04 If you're going to check this here and not just fa
BigBossZhiling 2017/04/17 21:56:11 Done.
366 result_html_string = result_details(json_file, args.cs_base_url,
331 args.bucket, args.server_url) 367 args.bucket, args.server_url)
332 print upload_to_google_bucket(result_html_string.encode('UTF-8'), 368 result_details_link = upload_to_google_bucket(
333 args.test_name, args.builder_name, 369 result_html_string.encode('UTF-8'),
334 args.build_number, args.bucket, 370 args.test_name, builder_name,
335 args.server_url, args.content_type) 371 build_number, args.bucket,
372 args.server_url, args.content_type)
373
374 if args.output_json:
375 with open(json_file) as original_json_file:
376 json_object = json.loads(original_json_file.read())
377 json_object['links'] = {'result_details': result_details_link}
378 with open(output_json, 'w') as f:
379 f.write(str(json_object))
380 else:
381 print result_details_link
336 else: 382 else:
337 raise IOError('--json-file %s not found.' % args.json_file) 383 raise IOError('--json-file %s not found.' % args.json_file)
338 384
339 385
340 if __name__ == '__main__': 386 if __name__ == '__main__':
341 sys.exit(main()) 387 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | testing/buildbot/chromium.linux.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698