Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 """TODO(dcampb): DO NOT SUBMIT without one-line documentation for print-layout-t est-paths.""" | |
|
qyearsley
2016/07/11 23:17:33
This line can be removed, and at the top of the fi
dcampb
2016/07/12 03:55:55
Corrections made.
| |
| 2 from webkitpy.common.net.layouttestresults import LayoutTestResults | |
| 3 from webkitpy.layout_tests.models.test_expectations import * | |
|
qyearsley
2016/07/11 23:17:33
It's best to avoid "wildcard imports" like these,
dcampb
2016/07/12 03:55:56
Ahh, never knew that. Changes made.
| |
| 4 from webkitpy.common.net.web import Web | |
| 5 from webkitpy.common.net import buildbot | |
| 6 from webkitpy.common.net import rietveld | |
| 7 from webkitpy.common.checkout.scm.git import Git | |
|
qyearsley
2016/07/11 23:17:32
Imports should be sorted, for consistency.
dcampb
2016/07/12 03:55:55
sorted by directory, file name or module name?
qyearsley
2016/07/12 16:43:35
Sorted lexicographically (which ends up to be by d
| |
| 8 import logging | |
|
qyearsley
2016/07/12 16:43:35
One more thing about import section format: Standa
| |
| 9 | |
| 10 _log = logging.getLogger(__name__) | |
| 11 | |
| 12 | |
| 13 TRY_BOTS = ['linux_chromium_rel_ng', 'mac_chromium_rel_ng', 'win_chromium_rel_ng '] | |
| 14 | |
| 15 | |
| 16 def Main(): | |
|
qyearsley
2016/07/11 23:17:32
For consistency with most of the other scripts her
dcampb
2016/07/12 03:55:55
done
| |
| 17 json_obj = {} | |
|
qyearsley
2016/07/11 23:17:33
This name can be made more descriptive; how would
dcampb
2016/07/12 03:55:55
Is that the same for local variable names in sub f
dcampb
2016/07/12 03:55:55
Is that the same for local variable names in sub f
qyearsley
2016/07/12 16:43:35
Yep -- there may be some cases where `obj, `data`
| |
| 18 counter = 0 | |
| 19 webo = Web() | |
|
raikiri
2016/07/11 18:46:55
maybe rename webo to something a little more clear
qyearsley
2016/07/11 23:17:33
I'd suggest just calling it web.
dcampb
2016/07/12 03:55:55
done, web_object?
dcampb
2016/07/12 19:57:03
just made it web, per qyearsley@ comment on line 2
| |
| 20 try_jobs_info = get_tryjobs_information(webo) | |
| 21 while counter < len(TRY_BOTS): | |
| 22 failing_paths = get_tryjob_results(try_jobs_info, webo, counter) | |
| 23 json_obj = merge_dicts(json_obj, failing_paths) | |
| 24 counter += 1 | |
| 25 return 0 | |
| 26 | |
| 27 | |
| 28 def get_tryjobs_information(web): | |
|
qyearsley
2016/07/11 23:17:33
tryjobs -> try_jobs
I prefer to treat this as two
dcampb
2016/07/12 03:55:55
done
| |
| 29 git_obj = Git('.') | |
|
qyearsley
2016/07/11 23:17:33
You could rename git_obj -> git; the _obj suffix d
dcampb
2016/07/12 03:55:55
makes sense, did the same for the web object.
| |
| 30 issue_number = git_obj.get_issue_number() | |
| 31 info = rietveld.latest_try_jobs(issue_number, TRY_BOTS, web) | |
| 32 return info | |
| 33 | |
| 34 | |
| 35 def _generate_results_dict(layout_test_list, test_results_object): | |
| 36 test_dict = {} | |
| 37 builder_name = test_results_object.builder_name() | |
| 38 if test_results_object.builder_name() in TRY_BOTS: | |
| 39 platform = builder_name[:builder_name.find("_")] | |
|
qyearsley
2016/07/11 23:17:33
We can't assume that builder names are always for
dcampb
2016/07/15 00:24:13
taken care of.
| |
| 40 for obj in layout_test_list: | |
|
qyearsley
2016/07/11 23:17:33
The name `obj` can be improved. In this case, it's
dcampb
2016/07/12 03:55:55
done
| |
| 41 test_dict[obj.test_name()] = {platform: {'expected': obj.expected_result s(), 'actual': obj.actual_results(), 'bug': 'crbug.com/626703'}} | |
| 42 return test_dict | |
| 43 | |
| 44 | |
| 45 def _strip_failing_results(data): | |
| 46 test_object = LayoutTestResults.results_from_string(data) | |
| 47 failing_paths = test_object.didnt_run_as_expected_results() | |
| 48 return _generate_results_dict(failing_paths, test_object) | |
| 49 | |
| 50 | |
| 51 def get_tryjob_results(try_jobs_data, web, index): | |
|
qyearsley
2016/07/11 23:17:32
tryjob -> try_job
dcampb
2016/07/12 03:55:55
done
| |
| 52 builder_name = try_jobs_data[index][0] | |
| 53 build_number = try_jobs_data[index][1] | |
| 54 builder = buildbot.Builder(builder_name, buildbot.BuildBot()) | |
| 55 url_components = (builder.results_url(), str(build_number), 'layout-test-res ults', 'failing_results.json') | |
| 56 results_url = '/'.join(url_components) | |
|
qyearsley
2016/07/11 23:17:32
The results URL can be constructed by methods on t
dcampb
2016/07/12 03:55:56
I believe I tried using it and it was giving me an
| |
| 57 json_data = web.get_binary(results_url) | |
| 58 failing_results_paths = _strip_failing_results(json_data) | |
| 59 return failing_results_paths | |
| 60 | |
| 61 | |
| 62 def _remove_duplicates(failing_paths): | |
| 63 seen = set() | |
| 64 new_list = [] | |
| 65 for dictionary in failing_paths: | |
| 66 path = tuple(dictionary.items()) | |
| 67 if path not in seen: | |
| 68 seen.add(path) | |
| 69 new_list.append(dict(path)) | |
| 70 return new_list | |
| 71 | |
| 72 | |
| 73 def merge_dicts(final, temp, path=None): | |
| 74 if path is None: | |
| 75 path = [] | |
|
raikiri
2016/07/11 18:46:55
can also be written:
path = path or []
| |
| 76 for key in temp: | |
| 77 if key in final: | |
| 78 if (isinstance(final[key], dict)) and isinstance(temp[key], dict): | |
| 79 merge_dicts(final[key], temp[key], path + [str(key)]) | |
|
raikiri
2016/07/11 18:46:55
iiuc this line seems to do nothing as you don't ke
dcampb
2016/07/12 03:55:55
this line recursively calls the function with a su
| |
| 80 elif final[key] == temp[key]: | |
| 81 pass | |
| 82 else: | |
| 83 raise Exception('Conflict at %s' % '.'.join(path)) | |
| 84 else: | |
| 85 final[key] = temp[key] | |
| 86 return final | |
| 87 | |
| 88 | |
| 89 if __name__ == '__main__': | |
| 90 Main() | |
| OLD | NEW |