llvm.org GIT mirror llvm / 07f4b9d
lit: modernize the lit configuration for the lit tests Summary: This also normalizes the config feature that represents the windows platform to "system-windows" as opposed to having both "windows" and "system-windows" Reviewers: asmith, probinson Subscribers: delcypher, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61798 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361998 91177308-0d34-0410-b5e6-96231b3b80d8 Stella Stamenova 2 months ago
3 changed file(s) with 17 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
33 import sys
44
55 import lit.formats
6 from lit.llvm import llvm_config
67
78 # Configuration file for the 'lit' test runner.
89
2425
2526 config.target_triple = '(unused)'
2627
27 src_root = os.path.join(config.test_source_root, '..')
2828 llvm_src_root = getattr(config, 'llvm_src_root', None)
29 if llvm_src_root != None:
30 # ``src_root`` may be in LLVM's binary build directory which does not contain
29 if llvm_src_root:
30 # ``test_source_root`` may be in LLVM's binary build directory which does not contain
3131 # ``lit.py``, so use `llvm_src_root` instead.
3232 lit_path = os.path.join(llvm_src_root, 'utils', 'lit')
3333 else:
34 lit_path = src_root
34 lit_path = os.path.join(config.test_source_root, '..')
3535
36 pythonpath_list = [lit_path] # Required because some tests import the lit module
36 # Required because some tests import the lit module
37 llvm_config.with_environment('PYTHONPATH', lit_path, append_path=True)
3738
38 # Ensure the user's PYTHONPATH is included.
39 if 'PYTHONPATH' in os.environ:
40 pythonpath_list.append(os.environ['PYTHONPATH'])
41 if 'PYTHONPATH' in config.environment:
42 pythonpath_list.append(config.environment['PYTHONPATH'])
43 config.environment['PYTHONPATH'] = os.pathsep.join(pythonpath_list)
39 # Add llvm and lit tools directories if this config is being loaded indirectly.
40 for attribute in ('llvm_tools_dir', 'lit_tools_dir'):
41 directory = getattr(config, attribute, None)
42 if directory:
43 llvm_config.with_environment('PATH', directory, append_path=True)
4444
45 config.substitutions.append(('%{src_root}', src_root))
4645 config.substitutions.append(('%{inputs}', os.path.join(
47 src_root, 'tests', 'Inputs')))
46 config.test_source_root, 'Inputs')))
4847 config.substitutions.append(('%{lit}', "%%{python} %s" % (
49 os.path.join(lit_path, 'lit.py'),)))
48 os.path.join(lit_path, 'lit.py'),)))
5049 config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
51
5250
5351 # Enable coverage.py reporting, assuming the coverage module has been installed
5452 # and sitecustomize.py in the virtualenv has been modified appropriately.
5553 if lit_config.params.get('check-coverage', None):
5654 config.environment['COVERAGE_PROCESS_START'] = os.path.join(
5755 os.path.dirname(__file__), ".coveragerc")
58
59 # Add a feature to detect the Python version.
60 config.available_features.add("python%d.%d" % (sys.version_info[0],
61 sys.version_info[1]))
6256
6357 # Add a feature to detect if psutil is available
6458 try:
6862 except ImportError:
6963 lit_config.warning('Could not import psutil. Some tests will be skipped and'
7064 ' the --timeout command line argument will not work.')
71
72 if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):
73 config.available_features.add('windows')
74
75 # Add llvm and lit tools directories if this config is being loaded indirectly.
76 path = config.environment['PATH']
77 for attribute in ('llvm_tools_dir', 'lit_tools_dir'):
78 directory = getattr(config, attribute, None)
79 if directory:
80 path = os.path.pathsep.join((directory, path))
81 config.environment['PATH'] = path
1515 key, = e.args
1616 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
1717
18 import lit.llvm
19 lit.llvm.initialize(lit_config, config)
20
1821 # Let the main config do the real work.
1922 lit_config.load_config(config, "@LLVM_BINARY_DIR@/utils/lit/tests/lit.cfg")
0 # REQUIRES: python-psutil
11
22 # llvm.org/PR33944
3 # This should be system-windows as windows does not cover all cases, but
4 # apparently neither does system-windows
5 # UNSUPPORTED: windows
3 # UNSUPPORTED: system-windows
64
75 # FIXME: This test is fragile because it relies on time which can
86 # be affected by system performance. In particular we are currently