blob: d36dd93e5bc281bf5225307e11c5165ed079f4e1 [file] [log] [blame]
Joe Gregorio48d361f2010-08-18 13:19:21 -04001#!/usr/bin/env python
Joe Gregoriofe695fb2010-08-30 12:04:04 -04002import glob
3import logging
4import os
5import sys
6import unittest
Joe Gregorio48d361f2010-08-18 13:19:21 -04007
8from trace import fullmodname
9try:
10 from tests.utils import cleanup
11except:
12 def cleanup():
13 pass
14
15sys.path.insert(0, os.getcwd())
16
Joe Gregoriofe695fb2010-08-30 12:04:04 -040017verbosity = 1
18if "-q" in sys.argv or '--quiet' in sys.argv:
19 verbosity = 0
20if "-v" in sys.argv or '--verbose' in sys.argv:
21 verbosity = 2
22
23if verbosity == 0:
24 logging.disable(logging.CRITICAL)
25elif verbosity == 1:
26 logging.disable(logging.ERROR)
27elif verbosity == 2:
28 logging.basicConfig(level=logging.DEBUG)
29
30
ade@google.com46179d32010-08-21 00:00:03 +010031def build_suite(folder):
32 # find all of the test modules
33 modules = map(fullmodname, glob.glob(os.path.join(folder, 'test_*.py')))
34 print "Running the tests found in the following modules:"
35 print modules
Joe Gregorio48d361f2010-08-18 13:19:21 -040036
ade@google.com46179d32010-08-21 00:00:03 +010037 # load all of the tests into a suite
38 try:
39 return unittest.TestLoader().loadTestsFromNames(modules)
40 except Exception, exception:
41 # attempt to produce a more specific message
42 for module in modules:
43 __import__(module)
44 raise
Joe Gregorio48d361f2010-08-18 13:19:21 -040045
ade@google.com46179d32010-08-21 00:00:03 +010046unit_tests = build_suite('tests')
47functional_tests = build_suite('functional_tests')
Joe Gregorio48d361f2010-08-18 13:19:21 -040048
ade@google.com46179d32010-08-21 00:00:03 +010049# run test suites
50unittest.TextTestRunner(verbosity=verbosity).run(unit_tests)
51unittest.TextTestRunner(verbosity=verbosity).run(functional_tests)
Joe Gregorio48d361f2010-08-18 13:19:21 -040052cleanup()