Chromium Code Reviews| Index: scripts/slave/recipe_modules/chromium_android/resources/test_results_presentation.py |
| diff --git a/scripts/slave/recipe_modules/chromium_android/resources/test_results_presentation.py b/scripts/slave/recipe_modules/chromium_android/resources/test_results_presentation.py |
| index 7ba1aa7e1743155387552525009b760e7308cef1..b138d2645f0e60becbc71bf769fe8a9a94e64740 100644 |
| --- a/scripts/slave/recipe_modules/chromium_android/resources/test_results_presentation.py |
| +++ b/scripts/slave/recipe_modules/chromium_android/resources/test_results_presentation.py |
| @@ -20,7 +20,7 @@ jinja_environment = jinja2.Environment( |
| loader = jinja2.FileSystemLoader(os.path.dirname(__file__))) |
| # Get result details from json path and then convert results to html. |
| -def result_details(json_path): |
| +def result_details(json_path, cs_base_url): |
| with open(json_path) as json_file: |
| json_object = json.loads(json_file.read()) |
| results_list = [] |
| @@ -33,21 +33,32 @@ def result_details(json_path): |
| 'duration': tr['elapsed_time_ms'], |
| 'output_snippet' : tr['output_snippet'] |
| } for tr in test_runs]) |
| - return results_to_html(results_list) |
| + return results_to_html(results_list, cs_base_url) |
| # Convert list of test results into html format. |
| -def results_to_html(results): |
| +def results_to_html(results, cs_base_url): |
| + def code_search(test): |
| + search = test.replace('#', '.') |
| + url = cs_base_url if cs_base_url else 'https://cs.chromium.org' |
| + return '%s/?q=%s&type=cs' % (url, search) |
| + |
| suite_row_dict = {} |
| test_row_list = [] |
| for result in results: |
| - data = [{'data': result['name'], 'class': 'align-left'}, |
| - {'data': result['status'], 'class': 'align-center'}, |
| - {'data': result['duration'], 'class': 'align-center'}, |
| - {'data': result['output_snippet'], 'class': 'align-left is-pre'}] |
| + # Constructing test_row_list. |
| + data = [{'data': result['name'], 'class': 'left', |
| + 'link': code_search(result['name'])}, |
| + {'data': result['status'], |
| + 'class': 'center ' + result['status'].lower()}, |
| + {'data': result['duration'], 'class': 'center'}, |
| + {'data': result['output_snippet'], |
| + 'class': 'left', 'is_pre': True}] |
| test_row_list.append(data) |
| - suite_name = result['name'][:result['name'].index('#')] |
| + # Constructing suite_row_dict |
| + test_case_path = result['name'] |
| + suite_name = test_case_path[:test_case_path.index('#')] |
| # 'suite_row' is [name, success_count, fail_count, all_count, time]. |
| SUCCESS_COUNT = 1 |
| FAIL_COUNT = 2 |
| @@ -57,11 +68,11 @@ def results_to_html(results): |
| if suite_name in suite_row_dict: |
| suite_row = suite_row_dict[suite_name] |
| else: |
| - suite_row = [{'data': suite_name, 'class' : 'align-left'}, |
| - {'data': 0, 'class': 'align-center'}, |
| - {'data': 0, 'class': 'align-center'}, |
| - {'data': 0, 'class': 'align-center'}, |
| - {'data': 0, 'class': 'align-center'}] |
| + suite_row = [{'data': suite_name, 'class' : 'left'}, |
| + {'data': 0, 'class': 'center'}, |
| + {'data': 0, 'class': 'center'}, |
| + {'data': 0, 'class': 'center'}, |
| + {'data': 0, 'class': 'center'}] |
| suite_row_dict[suite_name] = suite_row |
| suite_row[ALL_COUNT]['data'] += 1 |
| @@ -71,6 +82,12 @@ def results_to_html(results): |
| suite_row[FAIL_COUNT]['data'] += 1 |
| suite_row[TIME]['data'] += result['duration'] |
| + for suite in suite_row_dict.values(): |
| + if suite[FAIL_COUNT]['data'] > 0: |
| + suite[FAIL_COUNT]['class'] += ' failure' |
| + else: |
| + suite[FAIL_COUNT]['class'] += ' success' |
| + |
| test_table_values = { |
| 'table_id' : 'test_table', |
| 'table_headers' : [('text', 'test_name'), |
| @@ -78,6 +95,7 @@ def results_to_html(results): |
| ('number', 'duration'), |
| ('text', 'output_snippet'), |
| ], |
| + 'table_class' : 'info', |
|
the real yoland
2016/08/11 06:35:16
I think all the table class are just info, right?
BigBossZhiling
2016/08/11 06:49:45
Done.
|
| 'table_rows' : test_row_list, |
| } |
| @@ -89,6 +107,7 @@ def results_to_html(results): |
| ('number', 'all_tests'), |
| ('number', 'elapsed_time_ms'), |
| ], |
| + 'table_class' : 'info', |
| 'table_rows' : suite_row_dict.values(), |
| } |
| @@ -103,14 +122,16 @@ def main(): |
| parser.add_argument('--json-file', help='Path of json file.', required=True) |
| parser.add_argument('--html-file', help='Path to store html file.', |
| required=True) |
| + parser.add_argument('--cs-base-url', help='Base url for code search.') |
| + |
| args = parser.parse_args() |
| if os.path.exists(args.json_file): |
| - result_html_string = result_details(args.json_file) |
| + result_html_string = result_details(args.json_file, args.cs_base_url) |
| with open(args.html_file, 'w') as html: |
| html.write(result_html_string) |
| else: |
| - raise exception('Json file of result details is not found.') |
| + raise Exception('Json file of result details is not found.') |
| if __name__ == '__main__': |
| sys.exit(main()) |