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

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

Issue 2947603002: Merge test results presentation of multiple shards. (Closed)
Patch Set: address john's comments Created 3 years, 6 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
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
11 import os 11 import os
12 import sys 12 import sys
13 import urllib 13 import urllib
14 14
15
15 CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) 16 CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
16 BASE_DIR = os.path.abspath(os.path.join( 17 BASE_DIR = os.path.abspath(os.path.join(
17 CURRENT_DIR, '..', '..', '..', '..', '..')) 18 CURRENT_DIR, '..', '..', '..', '..', '..'))
18 19
19 sys.path.append(os.path.join(BASE_DIR, 'build', 'android')) 20 sys.path.append(os.path.join(BASE_DIR, 'build', 'android'))
20 from pylib.utils import google_storage_helper # pylint: disable=import-error 21 from pylib.utils import google_storage_helper # pylint: disable=import-error
22 from pylib.results.presentation import standard_gtest_merge
jbudorick 2017/06/21 21:05:06 nit: this should precede the google_storage_helper
BigBossZhiling 2017/06/21 22:10:24 Done.
21 23
22 sys.path.append(os.path.join(BASE_DIR, 'third_party')) 24 sys.path.append(os.path.join(BASE_DIR, 'third_party'))
23 import jinja2 # pylint: disable=import-error 25 import jinja2 # pylint: disable=import-error
24 JINJA_ENVIRONMENT = jinja2.Environment( 26 JINJA_ENVIRONMENT = jinja2.Environment(
25 loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), 27 loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
26 autoescape=True) 28 autoescape=True)
27 29
28 30
29 def cell(data, html_class='center'): 31 def cell(data, html_class='center'):
30 """Formats table cell data for processing in jinja template.""" 32 """Formats table cell data for processing in jinja template."""
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 if ((not 'buildnumber' in build_properties) or 395 if ((not 'buildnumber' in build_properties) or
394 (not 'buildername' in build_properties)): 396 (not 'buildername' in build_properties)):
395 raise parser.error('Build number/builder name not specified.') 397 raise parser.error('Build number/builder name not specified.')
396 build_number = build_properties['buildnumber'] 398 build_number = build_properties['buildnumber']
397 builder_name = build_properties['buildername'] 399 builder_name = build_properties['buildername']
398 elif args.build_number and args.builder_name: 400 elif args.build_number and args.builder_name:
399 build_number = args.build_number 401 build_number = args.build_number
400 builder_name = args.builder_name 402 builder_name = args.builder_name
401 403
402 if args.positional: 404 if args.positional:
403 if not len(args.positional) == 1: 405 if not len(args.positional) == 1:
jbudorick 2017/06/21 21:05:05 nit: flip this conditional around to if len(arg
BigBossZhiling 2017/06/21 22:10:25 Done.
404 raise parser.error('More than 1 json file specified.') 406 if args.output_json and args.summary_json:
405 json_file = args.positional[0] 407 standard_gtest_merge.standard_gtest_merge(
408 args.output_json, args.summary_json, args.positional)
409 json_file = args.output_json
410 else:
411 raise Exception('Arguments (output_json/summary_json) of'
jbudorick 2017/06/21 21:05:05 This was not what I meant. If args.output_json is
BigBossZhiling 2017/06/21 22:10:25 Done.
412 ' merge API are missing. ')
413 else:
414 json_file = args.positional[0]
406 elif args.json_file: 415 elif args.json_file:
407 json_file = args.json_file 416 json_file = args.json_file
408 417
409 if not os.path.exists(json_file): 418 if not os.path.exists(json_file):
410 raise IOError('--json-file %s not found.' % json_file) 419 raise IOError('--json-file %s not found.' % json_file)
411 420
412 # Link to result details presentation page is a part of the page. 421 # Link to result details presentation page is a part of the page.
413 result_html_string, dest, result_details_link = result_details( 422 result_html_string, dest, result_details_link = result_details(
414 json_file, args.cs_base_url, args.bucket, 423 json_file, args.cs_base_url, args.bucket,
415 args.test_name, builder_name, build_number) 424 args.test_name, builder_name, build_number)
(...skipping 10 matching lines...) Expand all
426 with open(json_file) as original_json_file: 435 with open(json_file) as original_json_file:
427 json_object = json.load(original_json_file) 436 json_object = json.load(original_json_file)
428 json_object['links'] = {'result_details': result_details_link} 437 json_object['links'] = {'result_details': result_details_link}
429 with open(args.output_json, 'w') as f: 438 with open(args.output_json, 'w') as f:
430 json.dump(json_object, f) 439 json.dump(json_object, f)
431 else: 440 else:
432 print result_details_link 441 print result_details_link
433 442
434 if __name__ == '__main__': 443 if __name__ == '__main__':
435 sys.exit(main()) 444 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698