| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import re | 5 import re |
| 6 | 6 |
| 7 | 7 |
| 8 class Test(object): | 8 class Test(object): |
| 9 """ | 9 """ |
| 10 Base class for tests that can be retried after deapplying a previously | 10 Base class for tests that can be retried after deapplying a previously |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 This makes it possible to keep the logic src-side as opposed | 92 This makes it possible to keep the logic src-side as opposed |
| 93 to the build repo most Chromium developers are unfamiliar with. | 93 to the build repo most Chromium developers are unfamiliar with. |
| 94 | 94 |
| 95 Another advantage is being to test changes to these scripts | 95 Another advantage is being to test changes to these scripts |
| 96 on trybots. | 96 on trybots. |
| 97 | 97 |
| 98 All new tests are strongly encouraged to use this infrastructure. | 98 All new tests are strongly encouraged to use this infrastructure. |
| 99 """ | 99 """ |
| 100 | 100 |
| 101 def __init__(self, name, script, all_compile_targets): | 101 def __init__(self, name, script): |
| 102 super(ScriptTest, self).__init__() | 102 super(ScriptTest, self).__init__() |
| 103 self._name = name | 103 self._name = name |
| 104 self._script = script | 104 self._script = script |
| 105 self._all_compile_targets = all_compile_targets | |
| 106 | 105 |
| 107 @property | 106 @property |
| 108 def name(self): | 107 def name(self): |
| 109 return self._name | 108 return self._name |
| 110 | 109 |
| 111 def compile_targets(self, api): | 110 @staticmethod |
| 112 try: | 111 def compile_targets(_): |
| 113 return self._all_compile_targets[self._script] | 112 # TODO(phajdan.jr): Implement this (http://crbug.com/422235). |
| 114 except KeyError: | 113 return [] |
| 115 # Not all scripts will have test data inside recipes, | |
| 116 # so return a default value. | |
| 117 # TODO(phajdan.jr): Revisit this when all script tests | |
| 118 # lists move src-side. We should be able to provide | |
| 119 # test data then. | |
| 120 if api.chromium._test_data.enabled: | |
| 121 return [] | |
| 122 | |
| 123 raise | |
| 124 | 114 |
| 125 def run(self, api, suffix): | 115 def run(self, api, suffix): |
| 126 name = self.name | 116 name = self.name |
| 127 if suffix: | 117 if suffix: |
| 128 name += ' (%s)' % suffix | 118 name += ' (%s)' % suffix |
| 129 try: | 119 try: |
| 130 api.python( | 120 api.python( |
| 131 name, | 121 name, |
| 132 # Enforce that all scripts are in the specified directory | 122 # Enforce that all scripts are in the specified directory |
| 133 # for consistency. | 123 # for consistency. |
| 134 api.path['checkout'].join( | 124 api.path['checkout'].join( |
| 135 'testing', 'scripts', api.path.basename(self._script)), | 125 'testing', 'scripts', api.path.basename(self._script)), |
| 136 args=(api.chromium.get_common_args_for_scripts() + | 126 args=['run', '--output', api.json.output()], |
| 137 ['run', '--output', api.json.output()]), | |
| 138 step_test_data=lambda: api.json.test_api.output( | 127 step_test_data=lambda: api.json.test_api.output( |
| 139 {'valid': True, 'failures': []})) | 128 {'valid': True, 'failures': []})) |
| 140 finally: | 129 finally: |
| 141 self._test_runs[suffix] = api.step.active_result | 130 self._test_runs[suffix] = api.step.active_result |
| 142 | 131 |
| 143 return self._test_runs[suffix] | 132 return self._test_runs[suffix] |
| 144 | 133 |
| 145 def has_valid_results(self, api, suffix): | 134 def has_valid_results(self, api, suffix): |
| 146 try: | 135 try: |
| 147 # Make sure the JSON includes all necessary data. | 136 # Make sure the JSON includes all necessary data. |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 GTestTest('crypto_unittests'), | 858 GTestTest('crypto_unittests'), |
| 870 GTestTest('gfx_unittests'), | 859 GTestTest('gfx_unittests'), |
| 871 GTestTest('url_unittests'), | 860 GTestTest('url_unittests'), |
| 872 GTestTest('content_unittests'), | 861 GTestTest('content_unittests'), |
| 873 GTestTest('net_unittests'), | 862 GTestTest('net_unittests'), |
| 874 GTestTest('ui_unittests'), | 863 GTestTest('ui_unittests'), |
| 875 GTestTest('ui_ios_unittests'), | 864 GTestTest('ui_ios_unittests'), |
| 876 GTestTest('sync_unit_tests'), | 865 GTestTest('sync_unit_tests'), |
| 877 GTestTest('sql_unittests'), | 866 GTestTest('sql_unittests'), |
| 878 ] | 867 ] |
| OLD | NEW |