| OLD | NEW |
| 1 # Copyright (c) 2010, Google Inc. All rights reserved. | 1 # Copyright (c) 2010, Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 def result_for_test(tree, test): | 50 def result_for_test(tree, test): |
| 51 parts = test.split('/') | 51 parts = test.split('/') |
| 52 for part in parts: | 52 for part in parts: |
| 53 if part not in tree: | 53 if part not in tree: |
| 54 return None | 54 return None |
| 55 tree = tree[part] | 55 tree = tree[part] |
| 56 return tree | 56 return tree |
| 57 | 57 |
| 58 | 58 |
| 59 class JSONTestResult(object): | 59 class JSONTestResult(object): |
| 60 |
| 60 def __init__(self, test_name, result_dict): | 61 def __init__(self, test_name, result_dict): |
| 61 self._test_name = test_name | 62 self._test_name = test_name |
| 62 self._result_dict = result_dict | 63 self._result_dict = result_dict |
| 63 | 64 |
| 64 def did_pass_or_run_as_expected(self): | 65 def did_pass_or_run_as_expected(self): |
| 65 return self.did_pass() or self.did_run_as_expected() | 66 return self.did_pass() or self.did_run_as_expected() |
| 66 | 67 |
| 67 def did_pass(self): | 68 def did_pass(self): |
| 68 return test_expectations.PASS in self._actual_as_tokens() | 69 return test_expectations.PASS in self._actual_as_tokens() |
| 69 | 70 |
| 70 def did_run_as_expected(self): | 71 def did_run_as_expected(self): |
| 71 return 'is_unexpected' not in self._result_dict | 72 return 'is_unexpected' not in self._result_dict |
| 72 | 73 |
| 73 def _tokenize(self, results_string): | 74 def _tokenize(self, results_string): |
| 74 tokens = map(TestExpectations.expectation_from_string, results_string.sp
lit(' ')) | 75 tokens = map(TestExpectations.expectation_from_string, results_string.sp
lit(' ')) |
| 75 if None in tokens: | 76 if None in tokens: |
| 76 _log.warning("Unrecognized result in %s" % results_string) | 77 _log.warning("Unrecognized result in %s" % results_string) |
| 77 return set(tokens) | 78 return set(tokens) |
| 78 | 79 |
| 79 @memoized | 80 @memoized |
| 80 def _actual_as_tokens(self): | 81 def _actual_as_tokens(self): |
| 81 actual_results = self._result_dict['actual'] | 82 actual_results = self._result_dict['actual'] |
| 82 return self._tokenize(actual_results) | 83 return self._tokenize(actual_results) |
| 83 | 84 |
| 84 | 85 |
| 85 # FIXME: This should be unified with ResultsSummary or other NRWT layout tests c
ode | 86 # FIXME: This should be unified with ResultsSummary or other NRWT layout tests c
ode |
| 86 # in the layout_tests package. | 87 # in the layout_tests package. |
| 87 # This doesn't belong in common.net, but we don't have a better place for it yet
. | 88 # This doesn't belong in common.net, but we don't have a better place for it yet
. |
| 88 class LayoutTestResults(object): | 89 class LayoutTestResults(object): |
| 90 |
| 89 @classmethod | 91 @classmethod |
| 90 def results_from_string(cls, string): | 92 def results_from_string(cls, string): |
| 91 if not string: | 93 if not string: |
| 92 return None | 94 return None |
| 93 | 95 |
| 94 content_string = json_results_generator.strip_json_wrapper(string) | 96 content_string = json_results_generator.strip_json_wrapper(string) |
| 95 json_dict = json.loads(content_string) | 97 json_dict = json.loads(content_string) |
| 96 if not json_dict: | 98 if not json_dict: |
| 97 return None | 99 return None |
| 98 return cls(json_dict) | 100 return cls(json_dict) |
| 99 | 101 |
| 100 def __init__(self, parsed_json): | 102 def __init__(self, parsed_json): |
| 101 self._results = parsed_json | 103 self._results = parsed_json |
| 102 | 104 |
| 103 def run_was_interrupted(self): | 105 def run_was_interrupted(self): |
| 104 return self._results["interrupted"] | 106 return self._results["interrupted"] |
| 105 | 107 |
| 106 def builder_name(self): | 108 def builder_name(self): |
| 107 return self._results["builder_name"] | 109 return self._results["builder_name"] |
| 108 | 110 |
| 109 def chromium_revision(self): | 111 def chromium_revision(self): |
| 110 return int(self._results["chromium_revision"]) | 112 return int(self._results["chromium_revision"]) |
| 111 | 113 |
| 112 def actual_results(self, test): | 114 def actual_results(self, test): |
| 113 result = result_for_test(self._results["tests"], test) | 115 result = result_for_test(self._results["tests"], test) |
| 114 if result: | 116 if result: |
| 115 return result["actual"] | 117 return result["actual"] |
| 116 return "" | 118 return "" |
| OLD | NEW |