0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
import unittest, os, sys
|
|
18 |
|
|
19 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
20 |
SOURCE_ROOT = os.path.normpath(os.path.join(ROOT_PATH, '../..'))
|
|
21 |
PLUGIN_SOURCE_ROOT = os.path.normpath(os.path.join(SOURCE_ROOT, 'plugins'))
|
|
22 |
assert os.path.split(SOURCE_ROOT)[1] == 'source'
|
|
23 |
assert os.path.split(PLUGIN_SOURCE_ROOT)[1] == 'plugins'
|
|
24 |
|
|
25 |
def _setup():
|
|
26 |
"""
|
|
27 |
Set up everything so that running "python cone_tool.py" finds the ConE
|
|
28 |
and plug-in modules.
|
|
29 |
"""
|
|
30 |
sys.path.append(SOURCE_ROOT)
|
|
31 |
sys.path.append(os.path.join(SOURCE_ROOT, 'testautomation'))
|
|
32 |
|
|
33 |
# Import the plugin_utils module from plugins/
|
|
34 |
sys.path.append(PLUGIN_SOURCE_ROOT)
|
|
35 |
import plugin_utils
|
|
36 |
del sys.path[-1]
|
|
37 |
|
|
38 |
# Collect all needed plug-in source directories (all in 'common')
|
|
39 |
plugin_sources = plugin_utils.find_plugin_sources(os.path.join(PLUGIN_SOURCE_ROOT, 'common'))
|
|
40 |
plugin_source_paths = [path for path, _ in plugin_sources]
|
|
41 |
|
|
42 |
paths = []
|
|
43 |
paths.append(SOURCE_ROOT)
|
|
44 |
paths.extend(plugin_source_paths)
|
|
45 |
os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + ';' + ';'.join(paths)
|
|
46 |
|
|
47 |
# Generate egg-info for the plug-ins if necessary
|
|
48 |
import build_egg_info
|
|
49 |
for path in plugin_source_paths:
|
|
50 |
build_egg_info.generate_egg_info(path)
|
|
51 |
|
|
52 |
_setup()
|
|
53 |
|
|
54 |
# Find all unittest_*.py files in this folder
|
|
55 |
import re
|
|
56 |
__all__ = filter(lambda name: re.match(r'^unittest_.*\.py$', name) != None, os.listdir(ROOT_PATH))
|
|
57 |
# Strip .py endings
|
|
58 |
__all__ = map(lambda name: name[:-3], __all__)
|
|
59 |
|
|
60 |
def collect_suite():
|
|
61 |
suite = unittest.TestSuite()
|
|
62 |
for test_module in __all__:
|
|
63 |
# Load the test module dynamically and add it to the test suite
|
|
64 |
module = __import__(test_module)
|
|
65 |
suite.addTests(unittest.TestLoader().loadTestsFromModule(module))
|
|
66 |
return suite
|
|
67 |
|
|
68 |
def runtests():
|
|
69 |
unittest.TextTestRunner(verbosity=2).run(collect_suite())
|
|
70 |
|
|
71 |
if __name__ == '__main__':
|
|
72 |
runtests()
|