| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if name.startswith('-'): # Exclude | 236 if name.startswith('-'): # Exclude |
| 237 excluded.extend(self._GetTestsFromName(self.TEST_PREFIX + name[1:])) | 237 excluded.extend(self._GetTestsFromName(self.TEST_PREFIX + name[1:])) |
| 238 else: | 238 else: |
| 239 args.extend(self._GetTestsFromName(self.TEST_PREFIX + name)) | 239 args.extend(self._GetTestsFromName(self.TEST_PREFIX + name)) |
| 240 for name in excluded: | 240 for name in excluded: |
| 241 args.remove(name) | 241 args.remove(name) |
| 242 if excluded: | 242 if excluded: |
| 243 logging.debug('Excluded %d test(s): %s' % (len(excluded), excluded)) | 243 logging.debug('Excluded %d test(s): %s' % (len(excluded), excluded)) |
| 244 return args | 244 return args |
| 245 | 245 |
| 246 def _FakePytestHack(self): |
| 247 """Adds a fake 'pytest' module to the system modules. |
| 248 |
| 249 A single test in text_handling_tests.py depends on the pytest module for |
| 250 its test skipping capabilities. Without pytest, we can not run any tests |
| 251 in the text_handling_tests.py module. |
| 252 |
| 253 We are not sure we want to add pytest to chrome's third party dependencies, |
| 254 so for now create a fake pytest module so that we can at least import and |
| 255 run all the tests that do not depend on it. Those depending on it are |
| 256 disabled. |
| 257 """ |
| 258 import imp |
| 259 sys.modules['pytest'] = imp.new_module('pytest') |
| 260 |
| 246 def _Run(self): | 261 def _Run(self): |
| 247 """Run the tests.""" | 262 """Run the tests.""" |
| 263 # TODO(kkania): Remove this hack. |
| 264 self._FakePytestHack() |
| 265 |
| 248 test_names = self._GetTestNames(self._args) | 266 test_names = self._GetTestNames(self._args) |
| 249 | 267 |
| 250 # The tests expect to run with preset 'driver' and 'webserver' class | 268 # The tests expect to run with preset 'driver' and 'webserver' class |
| 251 # properties. | 269 # properties. |
| 252 launcher = ChromeDriverLauncher(self._options.driver_exe, | 270 launcher = ChromeDriverLauncher(self._options.driver_exe, |
| 253 chromedriver_paths.WEBDRIVER_TEST_DATA) | 271 chromedriver_paths.WEBDRIVER_TEST_DATA) |
| 254 driver = WebDriver(launcher.GetURL(), {}) | 272 driver = WebDriver(launcher.GetURL(), {}) |
| 255 # The tests expect a webserver. Since ChromeDriver also operates as one, | 273 # The tests expect a webserver. Since ChromeDriver also operates as one, |
| 256 # just pass this dummy class with the right info. | 274 # just pass this dummy class with the right info. |
| 257 class DummyWebserver: | 275 class DummyWebserver: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 270 verbosity = 1 | 288 verbosity = 1 |
| 271 if self._options.verbose: | 289 if self._options.verbose: |
| 272 verbosity = 2 | 290 verbosity = 2 |
| 273 result = GTestTextTestRunner(verbosity=verbosity).run(test_suite) | 291 result = GTestTextTestRunner(verbosity=verbosity).run(test_suite) |
| 274 launcher.Kill() | 292 launcher.Kill() |
| 275 sys.exit(not result.wasSuccessful()) | 293 sys.exit(not result.wasSuccessful()) |
| 276 | 294 |
| 277 | 295 |
| 278 if __name__ == '__main__': | 296 if __name__ == '__main__': |
| 279 Main() | 297 Main() |
| OLD | NEW |