Chromium Code Reviews| Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/update_w3c_test_expectations.py |
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/update_w3c_test_expectations.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/update_w3c_test_expectations.py |
| index f74cfec2b08689fa8df3ffc05eaaa330ce405045..1b6e4cbd203edd5adae9b78c8466cf80ed2489b6 100644 |
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/update_w3c_test_expectations.py |
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/update_w3c_test_expectations.py |
| @@ -10,7 +10,7 @@ by retrieving the try job results for the current CL. |
| import logging |
| -from webkitpy.common.net import buildbot |
| +from webkitpy.common.net.buildbot import BuildBot |
| from webkitpy.common.net import rietveld |
| @@ -23,21 +23,17 @@ def main(host, port): |
| issue_number = expectations_line_adder.get_issue_number() |
| try_bots = expectations_line_adder.get_try_bots() |
| try_jobs = rietveld.latest_try_jobs(issue_number, try_bots, host.web) |
| - line_expectations_dict = {} |
| + test_expectations = {} |
| if not try_jobs: |
| print 'No Try Job information was collected.' |
| return 1 |
| - for try_job in try_jobs: |
| - builder_name = try_job[0] |
| - build_number = try_job[1] |
| - builder = buildbot.Builder(builder_name, host.buildbot) |
| - build = buildbot.Build(builder, build_number) |
| - platform_results_dict = expectations_line_adder.get_failing_results_dict(builder, build) |
| - line_expectations_dict = expectations_line_adder.merge_dicts(line_expectations_dict, platform_results_dict) |
| - for platform_results_dicts in line_expectations_dict.values(): |
| - platform_results_dicts = expectations_line_adder.merge_same_valued_keys(platform_results_dicts) |
| - line_list = expectations_line_adder.create_line_list(line_expectations_dict) |
| - expectations_line_adder.write_to_test_expectations(host, expectations_file, line_list) |
| + for job in try_jobs: |
| + platform_results = expectations_line_adder.get_failing_results_dict(BuildBot(), job.builder_name, job.build_number) |
| + test_expectations = expectations_line_adder.merge_dicts(test_expectations, platform_results) |
| + for test_name, platform_result in test_expectations.iteritems(): |
| + test_expectations[test_name] = expectations_line_adder.merge_same_valued_keys(platform_result) |
| + test_expectation_lines = expectations_line_adder.create_line_list(test_expectations) |
| + expectations_line_adder.write_to_test_expectations(host, expectations_file, test_expectation_lines) |
| class W3CExpectationsLineAdder(object): |
| @@ -65,7 +61,7 @@ class W3CExpectationsLineAdder(object): |
| }} |
| return test_dict |
| - def get_failing_results_dict(self, builder, build): |
| + def get_failing_results_dict(self, buildbot, builder_name, build_number): |
| """Returns a nested dict of failing test results. |
| Retrieves a full list of layout test results from a builder result URL. Collects |
| @@ -84,8 +80,8 @@ class W3CExpectationsLineAdder(object): |
| } |
| } |
| """ |
| - layout_test_results = builder.fetch_layout_test_results(build.results_url()) |
| - builder_name = layout_test_results.builder_name() |
| + results_url = buildbot.results_url(builder_name, build_number) |
| + layout_test_results = buildbot.fetch_layout_test_results(results_url) |
| platform = self._host.builders.port_name_for_builder_name(builder_name) |
| result_list = layout_test_results.didnt_run_as_expected_results() |
| failing_results_dict = self._generate_results_dict(platform, result_list) |
| @@ -129,29 +125,38 @@ class W3CExpectationsLineAdder(object): |
| dictionary: A dictionary with a dictionary as the value. |
| Returns: |
| - A dictionary with updated keys to reflect matching values of keys. |
| + A new dictionary with updated keys to reflect matching values of keys. |
| Example: { |
| 'one': {'foo': 'bar'}, |
| 'two': {'foo': 'bar'}, |
| - 'three': {'foo': bar'} |
| + 'three': {'foo': 'bar'} |
| } |
| - is converted to {('one', 'two', 'three'): {'foo': 'bar'}} |
| + is converted to a new dictionary with that contains |
| + {('one', 'two', 'three'): {'foo': 'bar'}} |
| """ |
| + merged_dict = {} |
| matching_value_keys = set() |
| - keys = dictionary.keys() |
| - is_last_item = False |
| - for index, item in enumerate(keys): |
| - if is_last_item: |
| + keys = sorted(dictionary.keys()) |
| + while keys: |
| + current_key = keys[0] |
| + found_match = False |
| + if current_key == keys[-1]: |
| + merged_dict[current_key] = dictionary[current_key] |
| + keys.remove(current_key) |
| break |
| - for i in range(index + 1, len(keys)): |
| - next_item = keys[i] |
| - if dictionary[item] == dictionary[next_item]: |
| - matching_value_keys.update([item, next_item]) |
| - dictionary[tuple(matching_value_keys)] = dictionary[item] |
| - is_last_item = next_item == keys[-1] |
| - del dictionary[item] |
| - del dictionary[next_item] |
| - return dictionary |
| + for next_item in keys[1:]: |
| + if dictionary[current_key] == dictionary[next_item]: |
| + found_match = True |
| + matching_value_keys.update([current_key, next_item]) |
| + if next_item == keys[-1]: |
| + if found_match: |
| + merged_dict[tuple(matching_value_keys)] = dictionary[current_key] |
| + keys = [k for k in keys if k not in matching_value_keys] |
| + else: |
| + merged_dict[current_key] = dictionary[current_key] |
| + keys.remove(current_key) |
| + matching_value_keys = set() |
| + return merged_dict |
| def get_expectations(self, results): |
| """Returns a list of test expectations for a given test dict. |
|
qyearsley
2016/07/26 23:59:43
In particular, it's a list of a expectations which
dcampb
2016/07/27 16:26:36
This function returns a list of actual test expect
qyearsley
2016/07/27 17:25:39
Right, so the output of this function determines t
dcampb
2016/07/27 18:17:50
agreed.
|
| @@ -172,16 +177,17 @@ class W3CExpectationsLineAdder(object): |
| A list of one or more test expectations with the first letter capitalized. Example: |
| ['Failure', 'Timeout'] |
|
qyearsley
2016/07/26 23:59:43
This comment can be updated now that this function
dcampb
2016/07/27 18:17:49
done
|
| """ |
| - expectations = [] |
| - failure_expectations = ['TEXT', 'FAIL', 'IMAGE+TEXT', 'IMAGE'] |
| + expectations = set() |
| + failure_expectations = ['SLOW', 'TEXT', 'FAIL', 'IMAGE+TEXT', 'IMAGE'] |
|
qyearsley
2016/07/26 23:59:43
I'm not sure if SLOW counts as a failure, and also
dcampb
2016/07/27 16:26:36
I do remember seeing an example of an expected tha
qyearsley
2016/07/27 17:25:39
Alright; here shouldn't be any more "baseline mism
|
| pass_crash_timeout = ['TIMEOUT', 'CRASH', 'PASS'] |
| - if results['expected'] in pass_crash_timeout and results['actual'] in failure_expectations: |
| - expectations.append('Failure') |
| - if results['expected'] in failure_expectations and results['actual'] in pass_crash_timeout: |
| - expectations.append(results['actual'].capitalize()) |
| - if results['expected'] in pass_crash_timeout and results['actual'] in pass_crash_timeout: |
| - expectations.append(results['actual'].capitalize()) |
| - expectations.append(results['expected'].capitalize()) |
| + for expected in results['expected'].split(): |
| + for actual in results['actual'].split(): |
|
qyearsley
2016/07/26 23:59:43
This morning I was saying that if there are multip
dcampb
2016/07/27 16:26:36
Would that result in a mismatch result? or wouldn'
dcampb
2016/07/27 16:44:24
Correction: This script only works with tests that
qyearsley
2016/07/27 17:25:39
What I meant was, since the dict passed in contain
dcampb
2016/07/27 18:17:49
I see what your saying. I agree, it could be refac
|
| + if expected in pass_crash_timeout and actual in failure_expectations: |
| + expectations.add('Failure') |
| + if expected in failure_expectations and actual in pass_crash_timeout: |
| + expectations.add(actual.capitalize()) |
| + if expected in pass_crash_timeout and actual in pass_crash_timeout: |
| + expectations.add(actual.capitalize()) |
|
qyearsley
2016/07/26 23:59:43
What if expected is "PASS" and actual is "PASS" --
dcampb
2016/07/27 16:26:36
That wouldn't happen as this script only parses te
dcampb
2016/07/27 16:44:24
Correction: This script parses tests that did not
qyearsley
2016/07/27 17:25:39
Yeah, those names aren't super clear. "Mismatch" w
dcampb
2016/07/27 18:17:50
understood. I think it would be wise to get this c
|
| return expectations |
| def create_line_list(self, merged_results): |
| @@ -210,17 +216,19 @@ class W3CExpectationsLineAdder(object): |
| line_list = [] |
| for test_name, platform_results in merged_results.iteritems(): |
| for platform in platform_results: |
| - platform_list = [] |
| - bug = [] |
| - expectations = [] |
| - if isinstance(platform, tuple): |
| - platform_list = list(platform) |
| - else: |
| - platform_list.append(platform) |
| - bug.append(platform_results[platform]['bug']) |
| - expectations = self.get_expectations(platform_results[platform]) |
| - line = '%s [ %s ] %s [ %s ]' % (bug[0], ' '.join(platform_list), test_name, ' '.join(expectations)) |
| - line_list.append(str(line)) |
| + if test_name.startswith('imported'): |
| + print platform_results |
| + platform_list = [] |
| + bug = [] |
| + expectations = [] |
| + if isinstance(platform, tuple): |
| + platform_list = list(platform) |
| + else: |
| + platform_list.append(platform) |
| + bug.append(platform_results[platform]['bug']) |
| + expectations = self.get_expectations(platform_results[platform]) |
| + line = '%s [ %s ] %s [ %s ]' % (bug[0], ' '.join(platform_list), test_name, ' '.join(expectations)) |
| + line_list.append(str(line)) |
| return line_list |
| def write_to_test_expectations(self, host, path, line_list): |