Daniel Dunbar | 40722cc | 2013-01-31 00:21:39 +0000 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | import os |
Daniel Dunbar | 6d0ed4c | 2013-08-14 05:07:09 +0000 | [diff] [blame] | 4 | import sys |
Daniel Dunbar | 40722cc | 2013-01-31 00:21:39 +0000 | [diff] [blame] | 5 | |
Daniel Dunbar | 72868c7 | 2013-08-09 21:39:17 +0000 | [diff] [blame] | 6 | import lit.formats |
| 7 | |
Daniel Dunbar | 40722cc | 2013-01-31 00:21:39 +0000 | [diff] [blame] | 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 | |
Daniel Dunbar | cd625f4e | 2013-09-14 01:19:17 +0000 | [diff] [blame] | 26 | config.target_triple = '(unused)' |
Daniel Dunbar | 40722cc | 2013-01-31 00:21:39 +0000 | [diff] [blame] | 27 | |
| 28 | src_root = os.path.join(config.test_source_root, '..') |
Daniel Dunbar | 25baa13 | 2013-01-31 01:23:26 +0000 | [diff] [blame] | 29 | config.environment['PYTHONPATH'] = src_root |
Daniel Dunbar | 40722cc | 2013-01-31 00:21:39 +0000 | [diff] [blame] | 30 | config.substitutions.append(('%{src_root}', src_root)) |
| 31 | config.substitutions.append(('%{inputs}', os.path.join( |
| 32 | src_root, 'tests', 'Inputs'))) |
Daniel Dunbar | 6d0ed4c | 2013-08-14 05:07:09 +0000 | [diff] [blame] | 33 | config.substitutions.append(('%{lit}', "%%{python} %s" % ( |
| 34 | os.path.join(src_root, 'lit.py'),))) |
| 35 | config.substitutions.append(('%{python}', sys.executable)) |
Daniel Dunbar | 40722cc | 2013-01-31 00:21:39 +0000 | [diff] [blame] | 36 | |
| 37 | # Enable coverage.py reporting, assuming the coverage module has been installed |
| 38 | # and sitecustomize.py in the virtualenv has been modified appropriately. |
Daniel Dunbar | 72868c7 | 2013-08-09 21:39:17 +0000 | [diff] [blame] | 39 | if lit_config.params.get('check-coverage', None): |
Daniel Dunbar | 40722cc | 2013-01-31 00:21:39 +0000 | [diff] [blame] | 40 | config.environment['COVERAGE_PROCESS_START'] = os.path.join( |
| 41 | os.path.dirname(__file__), ".coveragerc") |
Daniel Dunbar | cd625f4e | 2013-09-14 01:19:17 +0000 | [diff] [blame] | 42 | |
| 43 | # Add a feature to detect the Python version. |
| 44 | config.available_features.add("python%d.%d" % (sys.version_info[0], |
| 45 | sys.version_info[1])) |
Dan Liew | 7574241 | 2015-12-27 14:03:49 +0000 | [diff] [blame^] | 46 | |
| 47 | # Add a feature to detect if psutil is available |
| 48 | try: |
| 49 | import psutil |
| 50 | lit_config.note('Found python psutil module') |
| 51 | config.available_features.add("python-psutil") |
| 52 | except ImportError: |
| 53 | lit_config.warning('Could not import psutil. Some tests will be skipped and' |
| 54 | ' the --timeout command line argument will not work.') |