Dan Albert | aafac4b | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 1 | # -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: |
Daniel Dunbar | bbb2dae | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 2 | # Configuration file for the 'lit' test runner. |
Daniel Dunbar | bbb2dae | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 3 | import os |
Dan Albert | aafac4b | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 4 | import site |
Daniel Dunbar | bbb2dae | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 5 | |
Eric Fiselier | a68db1d | 2017-02-09 23:18:11 +0000 | [diff] [blame] | 6 | site.addsitedir(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'utils')) |
Daniel Dunbar | bbb2dae | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 7 | |
Dan Albert | a71db35 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 8 | |
Dan Albert | aafac4b | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 9 | # Tell pylint that we know config and lit_config exist somewhere. |
| 10 | if 'PYLINT_IMPORT' in os.environ: |
| 11 | config = object() |
| 12 | lit_config = object() |
Dan Albert | a71db35 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 13 | |
Daniel Dunbar | bbb2dae | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 14 | # name: The name of this test suite. |
| 15 | config.name = 'libc++' |
| 16 | |
| 17 | # suffixes: A list of file extensions to treat as test files. |
Louis Dionne | e39bc78 | 2020-04-03 11:06:26 -0400 | [diff] [blame] | 18 | config.suffixes = ['.pass.cpp', '.fail.cpp', '.sh.cpp', '.pass.mm'] |
Daniel Dunbar | bbb2dae | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 19 | |
| 20 | # test_source_root: The root path where tests are located. |
| 21 | config.test_source_root = os.path.dirname(__file__) |
| 22 | |
Louis Dionne | b0fd5bc | 2020-04-03 12:49:09 -0400 | [diff] [blame] | 23 | # Allow expanding substitutions that are based on other substitutions |
| 24 | config.recursiveExpansionLimit = 10 |
| 25 | |
Eric Fiselier | bbbbd11 | 2016-10-12 00:00:37 +0000 | [diff] [blame] | 26 | loaded_site_cfg = getattr(config, 'loaded_site_config', False) |
| 27 | if not loaded_site_cfg: |
| 28 | import libcxx.test.config |
| 29 | libcxx.test.config.loadSiteConfig(lit_config, config, 'libcxx_site_config', |
| 30 | 'LIBCXX_SITE_CONFIG') |
| 31 | |
Eric Fiselier | 26dcc93 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 32 | # Infer the test_exec_root from the libcxx_object root. |
Eric Fiselier | 7ca90ed | 2015-01-22 18:05:58 +0000 | [diff] [blame] | 33 | obj_root = getattr(config, 'libcxx_obj_root', None) |
Eric Fiselier | 26dcc93 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 34 | |
| 35 | # Check that the test exec root is known. |
Eric Fiselier | 7ca90ed | 2015-01-22 18:05:58 +0000 | [diff] [blame] | 36 | if obj_root is None: |
Eric Fiselier | 7ca90ed | 2015-01-22 18:05:58 +0000 | [diff] [blame] | 37 | obj_root = getattr(config, 'libcxx_obj_root', None) |
| 38 | if obj_root is None: |
| 39 | import tempfile |
| 40 | obj_root = tempfile.mkdtemp(prefix='libcxx-testsuite-') |
| 41 | lit_config.warning('Creating temporary directory for object root: %s' % |
| 42 | obj_root) |
| 43 | |
Dan Albert | 72f17a2 | 2020-03-13 12:23:45 -0700 | [diff] [blame] | 44 | if not config.test_exec_root: |
| 45 | config.test_exec_root = os.path.join(obj_root, 'test') |
Eric Fiselier | 26dcc93 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 46 | |
Dan Albert | aafac4b | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 47 | cfg_variant = getattr(config, 'configuration_variant', 'libcxx') |
Dan Albert | 7166d6c | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 48 | if cfg_variant: |
Eric Fiselier | bf22a28 | 2015-01-16 21:59:07 +0000 | [diff] [blame] | 49 | lit_config.note('Using configuration variant: %s' % cfg_variant) |
Dan Albert | 7166d6c | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 50 | |
Dan Albert | aafac4b | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 51 | # Load the Configuration class from the module name <cfg_variant>.test.config. |
| 52 | config_module_name = '.'.join([cfg_variant, 'test', 'config']) |
| 53 | config_module = __import__(config_module_name, fromlist=['Configuration']) |
| 54 | |
| 55 | configuration = config_module.Configuration(lit_config, config) |
Dan Albert | a71db35 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 56 | configuration.configure() |
Eric Fiselier | e0c23d7 | 2015-01-20 16:26:48 +0000 | [diff] [blame] | 57 | configuration.print_config_info() |
Louis Dionne | d75d788 | 2020-04-06 18:30:19 -0400 | [diff] [blame] | 58 | if lit_config.params.get('use_old_format', False): |
| 59 | lit_config.note("Using the old libc++ testing format") |
| 60 | config.test_format = configuration.get_test_format() |
| 61 | else: |
| 62 | lit_config.note("Using the new libc++ testing format") |
Louis Dionne | 493b0be | 2020-03-30 16:25:24 -0400 | [diff] [blame] | 63 | import libcxx.test.newformat |
| 64 | config.test_format = libcxx.test.newformat.CxxStandardLibraryTest() |