| Line | |
|---|
| 1 | #!/usr/bin/env python |
|---|
| 2 | |
|---|
| 3 | # Copyright: 2006 Marien Zwart <marienz@gentoo.org> |
|---|
| 4 | # License: GPL2 |
|---|
| 5 | |
|---|
| 6 | """Very minimal test runner.""" |
|---|
| 7 | import os.path |
|---|
| 8 | import sys |
|---|
| 9 | import unittest |
|---|
| 10 | |
|---|
| 11 | # ensure pkgcore is in sys.path |
|---|
| 12 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
|---|
| 13 | |
|---|
| 14 | # XXX nasty hack: point the plugin system at a predefined directory |
|---|
| 15 | # (to make it work without the global plugin registry being there). |
|---|
| 16 | # The plugin system reworking should kill this. |
|---|
| 17 | from pkgcore import const |
|---|
| 18 | const.plugins_dir = os.path.join(os.path.dirname(__file__), 'test-plugins') |
|---|
| 19 | |
|---|
| 20 | from pkgcore import test |
|---|
| 21 | from pkgcore.util import modules |
|---|
| 22 | |
|---|
| 23 | if __name__ == '__main__': |
|---|
| 24 | suites = [] |
|---|
| 25 | testpath = test.__path__[0] |
|---|
| 26 | for root, dirs, files in os.walk(testpath): |
|---|
| 27 | if '__init__.py' not in files: |
|---|
| 28 | continue |
|---|
| 29 | prefix = root[len(testpath):].replace(os.sep, '.') |
|---|
| 30 | for mod in files: |
|---|
| 31 | if mod.startswith('test') and mod.endswith('.py'): |
|---|
| 32 | module = modules.load_module('pkgcore.test%s.%s' % ( |
|---|
| 33 | prefix, mod[:-3])) |
|---|
| 34 | suite = unittest.defaultTestLoader.loadTestsFromModule(module) |
|---|
| 35 | suites.append(suite) |
|---|
| 36 | result = unittest.TextTestRunner().run(unittest.TestSuite(suites)) |
|---|
| 37 | sys.exit(not result.wasSuccessful()) |
|---|