3ed5bc9512973c77d963695c6bb4f64818c2106d
[oota-llvm.git] / utils / lit / tests / lit.cfg
1 # -*- Python -*-
2
3 import os
4 import sys
5
6 import lit.formats
7
8 # Configuration file for the 'lit' test runner.
9
10 # name: The name of this test suite.
11 config.name = 'lit'
12
13 # testFormat: The test format to use to interpret tests.
14 config.test_format = lit.formats.ShTest(execute_external=False)
15
16 # suffixes: A list of file extensions to treat as test files.
17 config.suffixes = ['.py']
18
19 # excludes: A list of individual files to exclude.
20 config.excludes = ['Inputs']
21
22 # test_source_root: The root path where tests are located.
23 config.test_source_root = os.path.dirname(__file__)
24 config.test_exec_root = config.test_source_root
25
26 config.target_triple = '(unused)'
27
28 src_root = os.path.join(config.test_source_root, '..')
29 llvm_src_root = getattr(config, 'llvm_src_root', None)
30 if llvm_src_root != None:
31   # ``src_root`` may be in LLVM's binary build directory which does not contain
32   # ``lit.py``, so use ``llvm_src_root`` instead.
33   lit_path = os.path.join(llvm_src_root, 'utils', 'lit')
34 else:
35   lit_path = src_root
36
37 config.environment['PYTHONPATH'] = lit_path # Required because some tests import the lit module
38 config.substitutions.append(('%{src_root}', src_root))
39 config.substitutions.append(('%{inputs}', os.path.join(
40             src_root, 'tests', 'Inputs')))
41 config.substitutions.append(('%{lit}', "%%{python} %s" % (
42             os.path.join(lit_path, 'lit.py'),)))
43 config.substitutions.append(('%{python}', sys.executable))
44
45 # Enable coverage.py reporting, assuming the coverage module has been installed
46 # and sitecustomize.py in the virtualenv has been modified appropriately.
47 if lit_config.params.get('check-coverage', None):
48     config.environment['COVERAGE_PROCESS_START'] = os.path.join(
49         os.path.dirname(__file__), ".coveragerc")
50
51 # Add a feature to detect the Python version.
52 config.available_features.add("python%d.%d" % (sys.version_info[0],
53                                                   sys.version_info[1]))
54
55 # Add a feature to detect if psutil is available
56 try:
57     import psutil
58     lit_config.note('Found python psutil module')
59     config.available_features.add("python-psutil")
60 except ImportError:
61     lit_config.warning('Could not import psutil. Some tests will be skipped and'
62                        ' the --timeout command line argument will not work.')
63
64 # Add llvm tools directory if this config is being loaded indirectly
65 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
66 if llvm_tools_dir != None:
67     path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
68     config.environment['PATH'] = path