OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Runs all tests in all unit test modules in this directory.""" | 6 """Runs all tests in all unit test modules in this directory.""" |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import unittest | 10 import unittest |
11 | 11 |
| 12 SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) |
| 13 |
12 | 14 |
13 def main(): | 15 def main(): |
| 16 # Running the tests depends on having the below modules in PYTHONPATH. |
| 17 sys.path.append(os.path.join(SRC, 'tools', 'telemetry')) |
| 18 sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) |
| 19 |
14 suite = unittest.TestSuite() | 20 suite = unittest.TestSuite() |
15 loader = unittest.TestLoader() | 21 loader = unittest.TestLoader() |
16 | |
17 # Add all tests in the directory. | |
18 script_dir = os.path.dirname(__file__) | 22 script_dir = os.path.dirname(__file__) |
19 suite.addTests(loader.discover(start_dir=script_dir, pattern='*_test.py')) | 23 suite.addTests(loader.discover(start_dir=script_dir, pattern='*_test.py')) |
20 | 24 |
21 print 'Running unit tests in %s...' % os.path.abspath(script_dir) | 25 print 'Running unit tests in %s...' % os.path.abspath(script_dir) |
22 result = unittest.TextTestRunner(verbosity=1).run(suite) | 26 result = unittest.TextTestRunner(verbosity=1).run(suite) |
23 return 0 if result.wasSuccessful() else 1 | 27 return 0 if result.wasSuccessful() else 1 |
24 | 28 |
25 | 29 |
26 if __name__ == '__main__': | 30 if __name__ == '__main__': |
27 sys.exit(main()) | 31 sys.exit(main()) |
OLD | NEW |