mbligh | fa29a2a | 2008-05-16 22:48:09 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
mbligh | f975133 | 2008-04-08 18:25:33 +0000 | [diff] [blame] | 2 | |
mbligh | 8c435fe | 2008-06-12 19:39:14 +0000 | [diff] [blame] | 3 | import os, sys |
mbligh | f975133 | 2008-04-08 18:25:33 +0000 | [diff] [blame] | 4 | import unittest |
mbligh | dc90601 | 2008-06-27 19:29:11 +0000 | [diff] [blame^] | 5 | import common |
mbligh | f975133 | 2008-04-08 18:25:33 +0000 | [diff] [blame] | 6 | |
mbligh | 3c9c93d | 2008-05-21 18:19:38 +0000 | [diff] [blame] | 7 | root = os.path.abspath(os.path.dirname(__file__)) |
mbligh | f975133 | 2008-04-08 18:25:33 +0000 | [diff] [blame] | 8 | suites = [] |
| 9 | def lister(dummy, dirname, files): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 10 | loader = unittest.TestLoader() |
| 11 | for f in files: |
| 12 | if f.endswith('_unittest.py'): |
| 13 | temp = os.path.join(dirname, f).strip('.py') |
mbligh | aadd083 | 2008-06-11 15:40:19 +0000 | [diff] [blame] | 14 | mod = 'autotest_lib' + temp[len(root):].replace('/', '.') |
| 15 | try: |
| 16 | suite = loader.loadTestsFromName(mod) |
| 17 | suites.append(suite) |
mbligh | 27d0cb9 | 2008-06-12 20:49:09 +0000 | [diff] [blame] | 18 | except Exception, err: |
| 19 | print "module failed to load: %s: %s" % (mod, err) |
mbligh | f975133 | 2008-04-08 18:25:33 +0000 | [diff] [blame] | 20 | |
| 21 | |
| 22 | if __name__ == "__main__": |
mbligh | 8c435fe | 2008-06-12 19:39:14 +0000 | [diff] [blame] | 23 | if len(sys.argv) == 2: |
| 24 | start = os.path.join(root, sys.argv[1]) |
| 25 | else: |
| 26 | start = root |
| 27 | os.path.walk(start, lister, None) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 28 | alltests = unittest.TestSuite(suites) |
| 29 | runner = unittest.TextTestRunner(verbosity=2) |
| 30 | runner.run(alltests) |