def test_strip_json_wrapper(self): json = "['contents']" self.assertEqual( json_results_generator.strip_json_wrapper( json_results_generator._JSON_PREFIX + json + json_results_generator._JSON_SUFFIX), json) self.assertEqual(json_results_generator.strip_json_wrapper(json), json)
def get_layout_test_step_name(self, build): url = '%s/testfile?%s' % (TEST_RESULTS_SERVER, urllib.urlencode({ 'builder': build.builder_name, 'buildnumber': build.build_number, 'name': 'full_results.json', # This forces the server to gives us JSON rather than an HTML page. 'callback': json_results_generator.JSON_CALLBACK, })) data = NetworkTransaction(return_none_on_404=True).run( lambda: self.fetch_file(url)) if not data: _log.debug('Got 404 response from:\n%s', url) return None # Strip out the callback data = json.loads(json_results_generator.strip_json_wrapper(data)) suites = [ entry['TestType'] for entry in data # Some suite names are like 'webkit_layout_tests on Intel GPU (with # patch)'. Only make sure it starts with webkit_layout_tests and # runs with a patch. This should be changed eventually to use actual # structured data from the test results server. if (entry['TestType'].startswith('webkit_layout_tests') and entry['TestType'].endswith('(with patch)')) ] # In manual testing, I sometimes saw results where the same suite was # repeated twice. De-duplicate here to try to catch this. suites = list(set(suites)) if len(suites) != 1: raise Exception( 'build %s on builder %s expected to only have one layout test ' 'step, instead has %s' % ( build.build_number, build.builder_name, suites)) return suites[0]
def get_layout_test_step_name(self, build): if not build.builder_name or not build.build_number: _log.debug('Builder name or build number is None') return None url = '%s/testfile?%s' % ( TEST_RESULTS_SERVER, urllib.urlencode({ 'builder': build.builder_name, 'buildnumber': build.build_number, 'name': 'full_results.json', # This forces the server to gives us JSON rather than an HTML page. 'callback': json_results_generator.JSON_CALLBACK, })) data = self.web.get_binary(url, return_none_on_404=True) if not data: _log.debug('Got 404 response from:\n%s', url) return None # Strip out the callback data = json.loads(json_results_generator.strip_json_wrapper(data)) suites = [ entry['TestType'] for entry in data # Some suite names are like 'blink_web_tests on Intel GPU (with # patch)'. Only make sure it starts with blink_web_tests and # runs with a patch. This should be changed eventually to use actual # structured data from the test results server. if (re.match(r'(blink_web_tests|wpt_tests_suite).*\(with patch\)$', entry['TestType']) # TODO(crbug.com/1178099) remove this once highdpi is stabilized # and no longer experimental. With the current config, # TestType doesn't have (with patch) suffix for highdpi while the # results url has (experimental, with patch) suffix. or entry['TestType'].startswith('high_dpi_blink_web_tests')) ] # In manual testing, I sometimes saw results where the same suite was # repeated twice. De-duplicate here to try to catch this. suites = list(set(suites)) if len(suites) != 1: raise Exception( 'build %s on builder %s expected to only have one web test ' 'step, instead has %s' % (build.build_number, build.builder_name, suites)) if suites[0].startswith('high_dpi_blink_web_tests'): # TODO(crbug.com/1178099) remove this once highdpi is stabilized # and no longer experimental. suites[0] = suites[0] + " (with patch, experimental)" return suites[0]
def results_from_string(cls, string, step_name=None): """Creates a WebTestResults object from a test result JSON string. Args: string: JSON string containing web test result. """ if not string: return None content_string = json_results_generator.strip_json_wrapper(string) json_dict = json.loads(content_string) if not json_dict: return None return cls(json_dict, step_name=step_name)
def get_layout_test_step_name(self, build): if not build.builder_name or not build.build_number: _log.debug('Builder name or build number is None') return None # We were not able to retrieve step name for some builders from # https://test-results.appspot.com. Read from config file instead step_name = self.builders.step_name_for_builder(build.builder_name) if step_name: return step_name url = '%s/testfile?%s' % ( TEST_RESULTS_SERVER, six.moves.urllib.parse.urlencode([ ('buildnumber', build.build_number), # This forces the server to gives us JSON rather than an HTML page. ('callback', json_results_generator.JSON_CALLBACK), ('builder', build.builder_name), ('name', 'full_results.json') ])) data = self.web.get_binary(url, return_none_on_404=True) if not data: _log.debug('Got 404 response from:\n%s', url) return None # Strip out the callback data = json.loads(json_results_generator.strip_json_wrapper(data)) suites = [ entry['TestType'] for entry in data # Some suite names are like 'blink_web_tests on Intel GPU (with # patch)'. Only make sure it starts with blink_web_tests and # runs with a patch. This should be changed eventually to use actual # structured data from the test results server. if re.match( r'(blink_web_tests|wpt_tests_suite|high_dpi_blink_web_tests).*\(with patch\)$', entry['TestType']) ] # In manual testing, I sometimes saw results where the same suite was # repeated twice. De-duplicate here to try to catch this. suites = list(set(suites)) if len(suites) != 1: raise Exception( 'build %s on builder %s expected to only have one web test ' 'step, instead has %s' % (build.build_number, build.builder_name, suites)) return suites[0]
def results_from_string(cls, string, chromium_revision=None): """Creates a LayoutTestResults object from a test result JSON string. Args: string: JSON string containing layout test result. chromium_revision: If given, it will override the chromium_revision field in json, to indicate the last revision that has completed uploading onto the storage server. chromium_revision can be a git hash or position number. """ if not string: return None content_string = json_results_generator.strip_json_wrapper(string) json_dict = json.loads(content_string) if not json_dict: return None return cls(json_dict, chromium_revision)