| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 NEEDS_MANUAL_REBASELINE_MODIFIER = 'needsmanualrebaseline' | 78 NEEDS_MANUAL_REBASELINE_MODIFIER = 'needsmanualrebaseline' |
| 79 PASS_EXPECTATION = 'pass' | 79 PASS_EXPECTATION = 'pass' |
| 80 SKIP_MODIFIER = 'skip' | 80 SKIP_MODIFIER = 'skip' |
| 81 SLOW_MODIFIER = 'slow' | 81 SLOW_MODIFIER = 'slow' |
| 82 WONTFIX_MODIFIER = 'wontfix' | 82 WONTFIX_MODIFIER = 'wontfix' |
| 83 | 83 |
| 84 TIMEOUT_EXPECTATION = 'timeout' | 84 TIMEOUT_EXPECTATION = 'timeout' |
| 85 | 85 |
| 86 MISSING_BUG_WARNING = 'Test lacks BUG specifier.' | 86 MISSING_BUG_WARNING = 'Test lacks BUG specifier.' |
| 87 | 87 |
| 88 def __init__(self, port, full_test_list, is_lint_mode): | 88 def __init__(self, port, all_tests, is_lint_mode): |
| 89 self._port = port | 89 self._port = port |
| 90 self._test_configuration_converter = TestConfigurationConverter(set(port
.all_test_configurations()), port.configuration_specifier_macros()) | 90 self._test_configuration_converter = TestConfigurationConverter(set(port
.all_test_configurations()), port.configuration_specifier_macros()) |
| 91 self._full_test_list = full_test_list | 91 |
| 92 if all_tests: |
| 93 self._all_tests = set(all_tests) |
| 94 else: |
| 95 self._all_tests = set() |
| 96 |
| 92 self._is_lint_mode = is_lint_mode | 97 self._is_lint_mode = is_lint_mode |
| 93 | 98 |
| 94 def parse(self, filename, expectations_string): | 99 def parse(self, filename, expectations_string): |
| 95 expectation_lines = [] | 100 expectation_lines = [] |
| 96 line_number = 0 | 101 line_number = 0 |
| 97 for line in expectations_string.split("\n"): | 102 for line in expectations_string.split("\n"): |
| 98 line_number += 1 | 103 line_number += 1 |
| 99 test_expectation = self._tokenize_line(filename, line, line_number) | 104 test_expectation = self._tokenize_line(filename, line, line_number) |
| 100 self._parse_line(test_expectation) | 105 self._parse_line(test_expectation) |
| 101 expectation_lines.append(test_expectation) | 106 expectation_lines.append(test_expectation) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 # Log a warning here since you hit this case any | 188 # Log a warning here since you hit this case any |
| 184 # time you update TestExpectations without syncing | 189 # time you update TestExpectations without syncing |
| 185 # the LayoutTests directory | 190 # the LayoutTests directory |
| 186 expectation_line.warnings.append('Path does not exist.') | 191 expectation_line.warnings.append('Path does not exist.') |
| 187 return False | 192 return False |
| 188 return True | 193 return True |
| 189 | 194 |
| 190 def _collect_matching_tests(self, expectation_line): | 195 def _collect_matching_tests(self, expectation_line): |
| 191 """Convert the test specification to an absolute, normalized | 196 """Convert the test specification to an absolute, normalized |
| 192 path and make sure directories end with the OS path separator.""" | 197 path and make sure directories end with the OS path separator.""" |
| 193 # FIXME: full_test_list can quickly contain a big amount of | 198 if not self._all_tests: |
| 194 # elements. We should consider at some point to use a more | |
| 195 # efficient structure instead of a list. Maybe a dictionary of | |
| 196 # lists to represent the tree of tests, leaves being test | |
| 197 # files and nodes being categories. | |
| 198 | |
| 199 if not self._full_test_list: | |
| 200 expectation_line.matching_tests = [expectation_line.path] | 199 expectation_line.matching_tests = [expectation_line.path] |
| 201 return | 200 return |
| 202 | 201 |
| 203 if not expectation_line.is_file: | 202 if not expectation_line.is_file: |
| 204 # this is a test category, return all the tests of the category. | 203 # this is a test category, return all the tests of the category. |
| 205 expectation_line.matching_tests = [test for test in self._full_test_
list if test.startswith(expectation_line.path)] | 204 expectation_line.matching_tests = [test for test in self._all_tests
if test.startswith(expectation_line.path)] |
| 206 return | 205 return |
| 207 | 206 |
| 208 # this is a test file, do a quick check if it's in the | 207 # this is a test file, do a quick check if it's in the |
| 209 # full test suite. | 208 # full test suite. |
| 210 if expectation_line.path in self._full_test_list: | 209 if expectation_line.path in self._all_tests: |
| 211 expectation_line.matching_tests.append(expectation_line.path) | 210 expectation_line.matching_tests.append(expectation_line.path) |
| 212 | 211 |
| 213 # FIXME: Update the original specifiers and remove this once the old syntax
is gone. | 212 # FIXME: Update the original specifiers and remove this once the old syntax
is gone. |
| 214 _configuration_tokens_list = [ | 213 _configuration_tokens_list = [ |
| 215 'Mac', 'SnowLeopard', 'Lion', 'Retina', 'MountainLion', 'Mavericks', | 214 'Mac', 'SnowLeopard', 'Lion', 'Retina', 'MountainLion', 'Mavericks', |
| 216 'Win', 'XP', 'Win7', | 215 'Win', 'XP', 'Win7', |
| 217 'Linux', | 216 'Linux', |
| 218 'Android', | 217 'Android', |
| 219 'Release', | 218 'Release', |
| 220 'Debug', | 219 'Debug', |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 # If reconstitute_only_these is an empty list, we want to return ori
ginal_string. | 1120 # If reconstitute_only_these is an empty list, we want to return ori
ginal_string. |
| 1122 # So we need to compare reconstitute_only_these to None, not just ch
eck if it's falsey. | 1121 # So we need to compare reconstitute_only_these to None, not just ch
eck if it's falsey. |
| 1123 if reconstitute_only_these is None or expectation_line in reconstitu
te_only_these: | 1122 if reconstitute_only_these is None or expectation_line in reconstitu
te_only_these: |
| 1124 return expectation_line.to_string(test_configuration_converter) | 1123 return expectation_line.to_string(test_configuration_converter) |
| 1125 return expectation_line.original_string | 1124 return expectation_line.original_string |
| 1126 | 1125 |
| 1127 def nones_out(expectation_line): | 1126 def nones_out(expectation_line): |
| 1128 return expectation_line is not None | 1127 return expectation_line is not None |
| 1129 | 1128 |
| 1130 return "\n".join(filter(nones_out, map(serialize, expectation_lines))) | 1129 return "\n".join(filter(nones_out, map(serialize, expectation_lines))) |
| OLD | NEW |