blob: c66b728aa7aeb4d91b43bcbb163f7291e87d1d2c [file] [log] [blame]
Joe Gregorio48d361f2010-08-18 13:19:21 -04001#!/usr/bin/env python
2import glob, unittest, os, sys
3
4from trace import fullmodname
5try:
6 from tests.utils import cleanup
7except:
8 def cleanup():
9 pass
10
11sys.path.insert(0, os.getcwd())
12
ade@google.com46179d32010-08-21 00:00:03 +010013def build_suite(folder):
14 # find all of the test modules
15 modules = map(fullmodname, glob.glob(os.path.join(folder, 'test_*.py')))
16 print "Running the tests found in the following modules:"
17 print modules
Joe Gregorio48d361f2010-08-18 13:19:21 -040018
ade@google.com46179d32010-08-21 00:00:03 +010019 # load all of the tests into a suite
20 try:
21 return unittest.TestLoader().loadTestsFromNames(modules)
22 except Exception, exception:
23 # attempt to produce a more specific message
24 for module in modules:
25 __import__(module)
26 raise
Joe Gregorio48d361f2010-08-18 13:19:21 -040027
28verbosity = 1
29if "-q" in sys.argv or '--quiet' in sys.argv:
30 verbosity = 0
31if "-v" in sys.argv or '--verbose' in sys.argv:
32 verbosity = 2
33
ade@google.com46179d32010-08-21 00:00:03 +010034unit_tests = build_suite('tests')
35functional_tests = build_suite('functional_tests')
Joe Gregorio48d361f2010-08-18 13:19:21 -040036
ade@google.com46179d32010-08-21 00:00:03 +010037# run test suites
38unittest.TextTestRunner(verbosity=verbosity).run(unit_tests)
39unittest.TextTestRunner(verbosity=verbosity).run(functional_tests)
Joe Gregorio48d361f2010-08-18 13:19:21 -040040cleanup()