def AddResults(self, test_results): # TODO(frankf): Differentiate between fail/crash/timeouts. conversion_map = [ (test_results.GetPass(), False, json_results_generator.JSONResultsGeneratorBase.PASS_RESULT), (test_results.GetFail(), True, json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), (test_results.GetCrash(), True, json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), (test_results.GetTimeout(), True, json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), (test_results.GetUnknown(), True, json_results_generator.JSONResultsGeneratorBase.NO_DATA_RESULT), ] for results_list, failed, modifier in conversion_map: for single_test_result in results_list: test_result = json_results_generator.TestResult( test=single_test_result.GetName(), failed=failed, elapsed_time=single_test_result.GetDuration() / 1000) # The WebKit TestResult object sets the modifier it based on test name. # Since we don't use the same test naming convention as WebKit the # modifier will be wrong, so we need to overwrite it. test_result.modifier = modifier self._test_results_map[ single_test_result.GetName()] = test_result
def testTestTimingsTrie(self): individual_test_timings = [] individual_test_timings.append( json_results_generator.TestResult('foo/bar/baz.html', elapsed_time=1.2)) individual_test_timings.append( json_results_generator.TestResult('bar.html', elapsed_time=0.0001)) trie = json_results_generator.TestTimingsTrie(individual_test_timings) expected_trie = { 'bar.html': 0, 'foo': { 'bar': { 'baz.html': 1200, } } } self.assertEqual(json.dumps(trie), json.dumps(expected_trie))
def _TestJSONGeneration(self, passed_tests_list, failed_tests_list): tests_set = set(passed_tests_list) | set(failed_tests_list) DISABLED_tests = set([t for t in tests_set if t.startswith('DISABLED_')]) FLAKY_tests = set([t for t in tests_set if t.startswith('FLAKY_')]) FAILS_tests = set([t for t in tests_set if t.startswith('FAILS_')]) PASS_tests = tests_set - (DISABLED_tests | FLAKY_tests | FAILS_tests) failed_tests = set(failed_tests_list) - DISABLED_tests failed_count_map = dict([(t, 1) for t in failed_tests]) test_timings = {} i = 0 for test in tests_set: test_timings[test] = float(self._num_runs * 100 + i) i += 1 test_results_map = dict() for test in tests_set: test_results_map[test] = json_results_generator.TestResult( test, failed=(test in failed_tests), elapsed_time=test_timings[test]) generator = json_results_generator.JSONResultsGeneratorBase( self.builder_name, self.build_name, self.build_number, '', None, # don't fetch past json results archive test_results_map) failed_count_map = dict([(t, 1) for t in failed_tests]) # Test incremental json results incremental_json = generator.GetJSON() self._VerifyJSONResults( tests_set, test_timings, failed_count_map, len(PASS_tests), len(DISABLED_tests), len(FLAKY_tests), len(DISABLED_tests | failed_tests), incremental_json, 1) # We don't verify the results here, but at least we make sure the code # runs without errors. generator.GenerateJSONOutput() generator.GenerateTimesMSFile()