| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Module containing information about the python-driven tests.""" | 5 """Module containing information about the python-driven tests.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 import tests_annotations | 10 import tests_annotations |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if annotations and len(annotations) == 1 and annotations[0] == 'SmallTest': | 86 if annotations and len(annotations) == 1 and annotations[0] == 'SmallTest': |
| 87 tests_without_annotation = [ | 87 tests_without_annotation = [ |
| 88 t for t in self.all_tests if | 88 t for t in self.all_tests if |
| 89 not tests_annotations.AnnotatedFunctions.GetTestAnnotations( | 89 not tests_annotations.AnnotatedFunctions.GetTestAnnotations( |
| 90 t.qualified_name)] | 90 t.qualified_name)] |
| 91 test_names = [t.qualified_name for t in tests_without_annotation] | 91 test_names = [t.qualified_name for t in tests_without_annotation] |
| 92 logging.warning('The following tests do not contain any annotation. ' | 92 logging.warning('The following tests do not contain any annotation. ' |
| 93 'Assuming "SmallTest":\n%s', | 93 'Assuming "SmallTest":\n%s', |
| 94 '\n'.join(test_names)) | 94 '\n'.join(test_names)) |
| 95 available_tests += tests_without_annotation | 95 available_tests += tests_without_annotation |
| 96 excluded_tests = [t for t in available_tests if | 96 if exclude_annotations: |
| 97 self._AnnotationIncludesTest(t, exclude_annotations)] | 97 excluded_tests = [t for t in available_tests if |
| 98 available_tests = list(set(available_tests) - set(excluded_tests)) | 98 self._AnnotationIncludesTest(t, exclude_annotations)] |
| 99 available_tests = list(set(available_tests) - set(excluded_tests)) |
| 99 available_tests = [t for t in available_tests if | 100 available_tests = [t for t in available_tests if |
| 100 self._NameFilterIncludesTest(t, name_filter)] | 101 self._NameFilterIncludesTest(t, name_filter)] |
| 101 | 102 |
| 102 return available_tests | 103 return available_tests |
| 103 | 104 |
| 104 def _AnnotationIncludesTest(self, test_info, annotation_filter_list): | 105 def _AnnotationIncludesTest(self, test_info, annotation_filter_list): |
| 105 """Checks whether a given test represented by test_info matches annotation. | 106 """Checks whether a given test represented by test_info matches annotation. |
| 106 | 107 |
| 107 Args: | 108 Args: |
| 108 test_info: TestInfo object representing the test | 109 test_info: TestInfo object representing the test |
| (...skipping 25 matching lines...) Expand all Loading... |
| 134 Foo.testBar and Bar.testFoo. 'foo' would not match either. | 135 Foo.testBar and Bar.testFoo. 'foo' would not match either. |
| 135 | 136 |
| 136 Args: | 137 Args: |
| 137 test_info: TestInfo object representing the test | 138 test_info: TestInfo object representing the test |
| 138 name_filter: substring to check for in the qualified name of the test | 139 name_filter: substring to check for in the qualified name of the test |
| 139 | 140 |
| 140 Returns: | 141 Returns: |
| 141 True if no name filter supplied or it matches; False otherwise. | 142 True if no name filter supplied or it matches; False otherwise. |
| 142 """ | 143 """ |
| 143 return not name_filter or name_filter in test_info.qualified_name | 144 return not name_filter or name_filter in test_info.qualified_name |
| OLD | NEW |