OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 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 """PyAuto: Python Interface to Chromium's Automation Proxy. | 7 """PyAuto: Python Interface to Chromium's Automation Proxy. |
8 | 8 |
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
10 For complete documentation on the functionality available, | 10 For complete documentation on the functionality available, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 os.path.join(chrome_src, 'xcodebuild', 'Release')], | 53 os.path.join(chrome_src, 'xcodebuild', 'Release')], |
54 'win32': [ os.path.join(chrome_src, 'chrome', 'Debug'), | 54 'win32': [ os.path.join(chrome_src, 'chrome', 'Debug'), |
55 os.path.join(chrome_src, 'chrome', 'Release')], | 55 os.path.join(chrome_src, 'chrome', 'Release')], |
56 'cygwin': [ os.path.join(chrome_src, 'chrome', 'Debug'), | 56 'cygwin': [ os.path.join(chrome_src, 'chrome', 'Debug'), |
57 os.path.join(chrome_src, 'chrome', 'Release')], | 57 os.path.join(chrome_src, 'chrome', 'Release')], |
58 } | 58 } |
59 deps_dirs = [ os.path.join(script_dir, os.pardir, | 59 deps_dirs = [ os.path.join(script_dir, os.pardir, |
60 os.pardir, os.pardir, 'third_party'), | 60 os.pardir, os.pardir, 'third_party'), |
61 script_dir, | 61 script_dir, |
62 ] | 62 ] |
63 sys.path += bin_dirs.get(sys.platform, []) + deps_dirs | 63 sys.path += map(os.path.normpath, bin_dirs.get(sys.platform, []) + deps_dirs) |
64 | 64 |
65 _LocateBinDirs() | 65 _LocateBinDirs() |
66 | 66 |
67 try: | 67 try: |
68 import pyautolib | 68 import pyautolib |
69 # Needed so that all additional classes (like: FilePath, GURL) exposed by | 69 # Needed so that all additional classes (like: FilePath, GURL) exposed by |
70 # swig interface get available in this module. | 70 # swig interface get available in this module. |
71 from pyautolib import * | 71 from pyautolib import * |
72 except ImportError: | 72 except ImportError: |
73 print >>sys.stderr, "Could not locate built libraries. Did you build?" | 73 print >>sys.stderr, "Could not locate built libraries. Did you build?" |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1297 if self._HasTestCases('__main__'): # we are running a test script | 1297 if self._HasTestCases('__main__'): # we are running a test script |
1298 args.append('__main__') # run the test cases found in it | 1298 args.append('__main__') # run the test cases found in it |
1299 else: # run tests from the test description file | 1299 else: # run tests from the test description file |
1300 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 1300 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
1301 logging.debug("Reading %s", pyauto_tests_file) | 1301 logging.debug("Reading %s", pyauto_tests_file) |
1302 if not os.path.exists(pyauto_tests_file): | 1302 if not os.path.exists(pyauto_tests_file): |
1303 logging.warn("%s missing. Cannot load tests." % pyauto_tests_file) | 1303 logging.warn("%s missing. Cannot load tests." % pyauto_tests_file) |
1304 else: | 1304 else: |
1305 args = self._LoadTestNamesFrom(pyauto_tests_file) | 1305 args = self._LoadTestNamesFrom(pyauto_tests_file) |
1306 args = args * self._options.repeat | 1306 args = args * self._options.repeat |
1307 logging.debug("Loading tests from %s", args) | 1307 logging.debug("Loading %d tests from %s", len(args), args) |
1308 loaded_tests = unittest.defaultTestLoader.loadTestsFromNames(args) | 1308 loaded_tests = unittest.defaultTestLoader.loadTestsFromNames(args) |
1309 return loaded_tests | 1309 return loaded_tests |
1310 | 1310 |
1311 def _LoadTestNamesFrom(self, filename): | 1311 def _LoadTestNamesFrom(self, filename): |
1312 modules= PyUITest.EvalDataFrom(filename) | 1312 modules= PyUITest.EvalDataFrom(filename) |
1313 platform = sys.platform | 1313 platform = sys.platform |
1314 if PyUITest.IsChromeOS(): # check if it's chromeos | 1314 if PyUITest.IsChromeOS(): # check if it's chromeos |
1315 platform = 'chromeos' | 1315 platform = 'chromeos' |
1316 assert platform in self._platform_map, '%s unsupported' % platform | 1316 assert platform in self._platform_map, '%s unsupported' % platform |
1317 all_names = modules.get('all', []) + \ | 1317 all_names = modules.get('all', []) + \ |
(...skipping 11 matching lines...) Expand all Loading... | |
1329 if excluded: | 1329 if excluded: |
1330 logging.debug('Excluded %d test(s): %s' % (len(excluded), excluded)) | 1330 logging.debug('Excluded %d test(s): %s' % (len(excluded), excluded)) |
1331 return args | 1331 return args |
1332 | 1332 |
1333 def _Run(self): | 1333 def _Run(self): |
1334 """Run the tests.""" | 1334 """Run the tests.""" |
1335 if self._options.wait_for_debugger: | 1335 if self._options.wait_for_debugger: |
1336 raw_input('Attach debugger to process %s and hit <enter> ' % os.getpid()) | 1336 raw_input('Attach debugger to process %s and hit <enter> ' % os.getpid()) |
1337 | 1337 |
1338 suite_args = [sys.argv[0]] | 1338 suite_args = [sys.argv[0]] |
1339 if self._options.chrome_flags: | 1339 chrome_flags = self._options.chrome_flags |
1340 suite_args.append('--extra-chrome-flags=' + self._options.chrome_flags) | 1340 # Enable crash reporter by default on posix. It's already enabled on win. |
John Grabowski
2010/07/27 23:35:30
If already enabled by default on windows (in the b
Nirnimesh
2010/07/28 01:14:03
The win flow is somewhat different, esp after the
| |
1341 if PyUITest.IsPosix(): | |
1342 chrome_flags += ' --enable-crash-reporter' | |
1343 if chrome_flags: | |
1344 suite_args.append('--extra-chrome-flags=%s' % chrome_flags) | |
1341 pyauto_suite = PyUITestSuite(suite_args) | 1345 pyauto_suite = PyUITestSuite(suite_args) |
1342 loaded_tests = self._LoadTests(self._args) | 1346 loaded_tests = self._LoadTests(self._args) |
1343 pyauto_suite.addTests(loaded_tests) | 1347 pyauto_suite.addTests(loaded_tests) |
1344 verbosity = 1 | 1348 verbosity = 1 |
1345 if self._options.verbose: | 1349 if self._options.verbose: |
1346 verbosity = 2 | 1350 verbosity = 2 |
1347 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite) | 1351 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite) |
1348 del loaded_tests # Need to destroy test cases before the suite | 1352 del loaded_tests # Need to destroy test cases before the suite |
1349 del pyauto_suite | 1353 del pyauto_suite |
1350 sys.exit(not result.wasSuccessful()) | 1354 sys.exit(not result.wasSuccessful()) |
1351 | 1355 |
1352 | 1356 |
1353 if __name__ == '__main__': | 1357 if __name__ == '__main__': |
1354 Main() | 1358 Main() |
OLD | NEW |