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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 actual_results = self._result_dict['actual'] | 92 actual_results = self._result_dict['actual'] |
93 return self._tokenize(actual_results) | 93 return self._tokenize(actual_results) |
94 | 94 |
95 @memoized | 95 @memoized |
96 def _expected_as_tokens(self): | 96 def _expected_as_tokens(self): |
97 actual_results = self._result_dict['expected'] | 97 actual_results = self._result_dict['expected'] |
98 return self._tokenize(actual_results) | 98 return self._tokenize(actual_results) |
99 | 99 |
100 def _failure_types_from_actual_result(self, actual): | 100 def _failure_types_from_actual_result(self, actual): |
101 # FIXME: There doesn't seem to be a full list of all possible values of | 101 # FIXME: There doesn't seem to be a full list of all possible values of |
102 # 'actual' anywhere. However JSONLayoutResultsGenerator.FAILURE_TO_CHAR | 102 # 'actual' anywhere. |
103 # is a useful reference as that's for "old" style results.json files | |
104 # | 103 # |
105 # FIXME: TEXT, IMAGE_PLUS_TEXT, and AUDIO are obsolete but we keep them
for | 104 # FIXME: TEXT, IMAGE_PLUS_TEXT, and AUDIO are obsolete but we keep them
for |
106 # now so that we can parse old results.json files. | 105 # now so that we can parse old results.json files. |
107 if actual == test_expectations.PASS: | 106 if actual == test_expectations.PASS: |
108 return [] | 107 return [] |
109 elif actual == test_expectations.FAIL: | 108 elif actual == test_expectations.FAIL: |
110 return [test_failures.FailureTextMismatch(), test_failures.FailureIm
ageHashMismatch(), test_failures.FailureAudioMismatch()] | 109 return [test_failures.FailureTextMismatch(), test_failures.FailureIm
ageHashMismatch(), test_failures.FailureAudioMismatch()] |
111 elif actual == test_expectations.TEXT: | 110 elif actual == test_expectations.TEXT: |
112 return [test_failures.FailureTextMismatch()] | 111 return [test_failures.FailureTextMismatch()] |
113 elif actual == test_expectations.IMAGE: | 112 elif actual == test_expectations.IMAGE: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 content_string = json_results_generator.strip_json_wrapper(json_string) | 145 content_string = json_results_generator.strip_json_wrapper(json_string) |
147 json_dict = json.loads(content_string) | 146 json_dict = json.loads(content_string) |
148 | 147 |
149 json_results = [] | 148 json_results = [] |
150 for_each_test(json_dict['tests'], lambda test, result: json_results.appe
nd(JSONTestResult(test, result))) | 149 for_each_test(json_dict['tests'], lambda test, result: json_results.appe
nd(JSONTestResult(test, result))) |
151 | 150 |
152 # FIXME: What's the short sexy python way to filter None? | 151 # FIXME: What's the short sexy python way to filter None? |
153 # I would use [foo.bar() for foo in foos if foo.bar()] but bar() is expe
nsive. | 152 # I would use [foo.bar() for foo in foos if foo.bar()] but bar() is expe
nsive. |
154 unexpected_failures = [result.test_result() for result in json_results i
f not result.did_pass_or_run_as_expected()] | 153 unexpected_failures = [result.test_result() for result in json_results i
f not result.did_pass_or_run_as_expected()] |
155 return filter(lambda a: a, unexpected_failures) | 154 return filter(lambda a: a, unexpected_failures) |
OLD | NEW |