8 from lit.llvm import llvm_config
10 # Configuration file for the 'lit' test runner.
12 # name: The name of this test suite.
15 # testFormat: The test format to use to interpret tests.
16 config.test_format = lit.formats.ShTest(execute_external=False)
18 # suffixes: A list of file extensions to treat as test files.
19 config.suffixes = ['.py']
21 # excludes: A list of individual files to exclude.
22 config.excludes = ['Inputs']
24 # test_source_root: The root path where tests are located.
25 config.test_source_root = os.path.dirname(__file__)
26 config.test_exec_root = config.test_source_root
28 config.target_triple = '(unused)'
30 llvm_src_root = getattr(config, 'llvm_src_root', None)
32 # ``test_source_root`` may be in LLVM's binary build directory which does not contain
33 # ``lit.py``, so use `llvm_src_root` instead.
34 lit_path = os.path.join(llvm_src_root, 'utils', 'lit')
36 lit_path = os.path.join(config.test_source_root, '..')
38 # Required because some tests import the lit module
40 llvm_config.with_environment('PYTHONPATH', lit_path, append_path=True)
42 config.environment['PYTHONPATH'] = os.pathsep.join([lit_path])
44 # Add llvm and lit tools directories if this config is being loaded indirectly.
45 # In this case, we can also expect llvm_config to have been imported correctly.
46 for attribute in ('llvm_tools_dir', 'lit_tools_dir'):
47 directory = getattr(config, attribute, None)
49 llvm_config.with_environment('PATH', directory, append_path=True)
51 config.substitutions.append(('%{inputs}', os.path.join(
52 config.test_source_root, 'Inputs')))
53 config.substitutions.append(('%{lit}', "%%{python} %s" % (
54 os.path.join(lit_path, 'lit.py'),)))
55 config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
57 # Enable coverage.py reporting, assuming the coverage module has been installed
58 # and sitecustomize.py in the virtualenv has been modified appropriately.
59 if lit_config.params.get('check-coverage', None):
60 config.environment['COVERAGE_PROCESS_START'] = os.path.join(
61 os.path.dirname(__file__), ".coveragerc")
63 # Add a feature to detect if psutil is available
64 supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
66 config.available_features.add("lit-max-individual-test-time")
68 lit_config.warning('Setting a timeout per test not supported. ' + errormsg
69 + ' Some tests will be skipped and the --timeout'
70 ' command line argument will not work.')
72 # When running the lit tests standalone, we want to define the same features
73 # that the llvm_config defines. This means that the 'system-windows' feature
74 # (and any others) need to match the names in llvm_config for consistency
76 if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):
77 config.available_features.add('system-windows')
79 # For each of lit's internal shell commands ('env', 'cd', 'diff', etc.), put
80 # a fake command that always fails at the start of PATH. This helps us check
81 # that we always use lit's internal version rather than some external version
82 # that might not be present or behave correctly on all platforms. Don't do
83 # this for 'echo' because an external version is used when it appears in a
84 # pipeline. Don't do this for ':' because it doesn't appear to be a valid file
86 test_bin = os.path.join(os.path.dirname(__file__), 'Inputs', 'fake-externals')
87 config.environment['PATH'] = os.path.pathsep.join((test_bin,
88 config.environment['PATH']))