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

Side by Side Diff: build/android/test_runner.py

Issue 1971433002: ABANDONED [Android] Expose each try result in test results JSON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes: use last result in an iteration, only use iteration_results in exit code determination Created 4 years, 7 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 | « build/android/pylib/remote/device/remote_device_test_run.py ('k') | no next file » | 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 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 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 """Runs all types of tests from one unified interface.""" 7 """Runs all types of tests from one unified interface."""
8 8
9 import argparse 9 import argparse
10 import collections 10 import collections
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 logging.fatal(message) 842 logging.fatal(message)
843 sys.exit(constants.INFRA_EXIT_CODE) 843 sys.exit(constants.INFRA_EXIT_CODE)
844 844
845 if args.command not in _SUPPORTED_IN_PLATFORM_MODE: 845 if args.command not in _SUPPORTED_IN_PLATFORM_MODE:
846 infra_error('%s is not yet supported in platform mode' % args.command) 846 infra_error('%s is not yet supported in platform mode' % args.command)
847 847
848 with environment_factory.CreateEnvironment(args, infra_error) as env: 848 with environment_factory.CreateEnvironment(args, infra_error) as env:
849 with test_instance_factory.CreateTestInstance(args, infra_error) as test: 849 with test_instance_factory.CreateTestInstance(args, infra_error) as test:
850 with test_run_factory.CreateTestRun( 850 with test_run_factory.CreateTestRun(
851 args, env, test, infra_error) as test_run: 851 args, env, test, infra_error) as test_run:
852 results = [] 852 all_raw_results = []
853 all_iteration_results = []
853 repetitions = (xrange(args.repeat + 1) if args.repeat >= 0 854 repetitions = (xrange(args.repeat + 1) if args.repeat >= 0
854 else itertools.count()) 855 else itertools.count())
855 result_counts = collections.defaultdict( 856 result_counts = collections.defaultdict(
856 lambda: collections.defaultdict(int)) 857 lambda: collections.defaultdict(int))
857 iteration_count = 0 858 iteration_count = 0
858 for _ in repetitions: 859 for _ in repetitions:
859 iteration_results = test_run.RunTests() 860 raw_results = test_run.RunTests()
860 if iteration_results is not None: 861 if not raw_results:
861 iteration_count += 1 862 continue
862 results.append(iteration_results) 863
863 for r in iteration_results.GetAll(): 864 all_raw_results.extend(raw_results)
864 result_counts[r.GetName()][r.GetType()] += 1 865
865 report_results.LogFull( 866 iteration_results = base_test_result.TestRunResults()
866 results=iteration_results, 867 for r in reversed(raw_results):
867 test_type=test.TestType(), 868 iteration_results.AddTestRunResults(r)
868 test_package=test_run.TestPackage(), 869 all_iteration_results.append(iteration_results)
869 annotation=getattr(args, 'annotations', None), 870
870 flakiness_server=getattr(args, 'flakiness_dashboard_server', 871 iteration_count += 1
871 None)) 872 for r in iteration_results.GetAll():
872 if args.break_on_failure and not iteration_results.DidRunPass(): 873 result_counts[r.GetName()][r.GetType()] += 1
873 break 874 report_results.LogFull(
875 results=iteration_results,
876 test_type=test.TestType(),
877 test_package=test_run.TestPackage(),
878 annotation=getattr(args, 'annotations', None),
879 flakiness_server=getattr(args, 'flakiness_dashboard_server',
880 None))
881 if args.break_on_failure and not iteration_results.DidRunPass():
882 break
874 883
875 if iteration_count > 1: 884 if iteration_count > 1:
876 # display summary results 885 # display summary results
877 # only display results for a test if at least one test did not pass 886 # only display results for a test if at least one test did not pass
878 all_pass = 0 887 all_pass = 0
879 tot_tests = 0 888 tot_tests = 0
880 for test_name in result_counts: 889 for test_name in result_counts:
881 tot_tests += 1 890 tot_tests += 1
882 if any(result_counts[test_name][x] for x in ( 891 if any(result_counts[test_name][x] for x in (
883 base_test_result.ResultType.FAIL, 892 base_test_result.ResultType.FAIL,
884 base_test_result.ResultType.CRASH, 893 base_test_result.ResultType.CRASH,
885 base_test_result.ResultType.TIMEOUT, 894 base_test_result.ResultType.TIMEOUT,
886 base_test_result.ResultType.UNKNOWN)): 895 base_test_result.ResultType.UNKNOWN)):
887 logging.critical( 896 logging.critical(
888 '%s: %s', 897 '%s: %s',
889 test_name, 898 test_name,
890 ', '.join('%s %s' % (str(result_counts[test_name][i]), i) 899 ', '.join('%s %s' % (str(result_counts[test_name][i]), i)
891 for i in base_test_result.ResultType.GetTypes())) 900 for i in base_test_result.ResultType.GetTypes()))
892 else: 901 else:
893 all_pass += 1 902 all_pass += 1
894 903
895 logging.critical('%s of %s tests passed in all %s runs', 904 logging.critical('%s of %s tests passed in all %s runs',
896 str(all_pass), 905 str(all_pass),
897 str(tot_tests), 906 str(tot_tests),
898 str(iteration_count)) 907 str(iteration_count))
899 908
900 if args.json_results_file: 909 if args.json_results_file:
901 json_results.GenerateJsonResultsFile( 910 json_results.GenerateJsonResultsFile(
902 results, args.json_results_file) 911 all_raw_results, args.json_results_file)
903 912
904 return (0 if all(r.DidRunPass() for r in results) 913 return (0 if all(r.DidRunPass() for r in all_iteration_results)
905 else constants.ERROR_EXIT_CODE) 914 else constants.ERROR_EXIT_CODE)
906 915
907 916
908 CommandConfigTuple = collections.namedtuple( 917 CommandConfigTuple = collections.namedtuple(
909 'CommandConfigTuple', 918 'CommandConfigTuple',
910 ['add_options_func', 'help_txt']) 919 ['add_options_func', 'help_txt'])
911 VALID_COMMANDS = { 920 VALID_COMMANDS = {
912 'gtest': CommandConfigTuple( 921 'gtest': CommandConfigTuple(
913 AddGTestOptions, 922 AddGTestOptions,
914 'googletest-based C++ tests'), 923 'googletest-based C++ tests'),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 if e.is_infra_error: 972 if e.is_infra_error:
964 return constants.INFRA_EXIT_CODE 973 return constants.INFRA_EXIT_CODE
965 return constants.ERROR_EXIT_CODE 974 return constants.ERROR_EXIT_CODE
966 except: # pylint: disable=W0702 975 except: # pylint: disable=W0702
967 logging.exception('Unrecognized error occurred.') 976 logging.exception('Unrecognized error occurred.')
968 return constants.ERROR_EXIT_CODE 977 return constants.ERROR_EXIT_CODE
969 978
970 979
971 if __name__ == '__main__': 980 if __name__ == '__main__':
972 sys.exit(main()) 981 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/remote/device/remote_device_test_run.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698