Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 1 | # -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 2 | |
| 3 | # Configuration file for the 'lit' test runner. |
| 4 | |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 5 | |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 6 | import os |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 7 | import site |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 8 | |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 9 | site.addsitedir(os.path.dirname(__file__)) |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 10 | |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 11 | |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 12 | # Tell pylint that we know config and lit_config exist somewhere. |
| 13 | if 'PYLINT_IMPORT' in os.environ: |
| 14 | config = object() |
| 15 | lit_config = object() |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 16 | |
| 17 | # name: The name of this test suite. |
| 18 | config.name = 'libc++abi' |
| 19 | |
| 20 | # suffixes: A list of file extensions to treat as test files. |
Logan Chien | cc4f512 | 2016-11-13 14:44:41 +0000 | [diff] [blame] | 21 | config.suffixes = ['.cpp', '.s'] |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 22 | |
| 23 | # test_source_root: The root path where tests are located. |
| 24 | config.test_source_root = os.path.dirname(__file__) |
| 25 | |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 26 | # Infer the libcxx_test_source_root for configuration import. |
| 27 | # If libcxx_source_root isn't specified in the config, assume that the libcxx |
| 28 | # and libcxxabi source directories are sibling directories. |
Eric Fiselier | 9a9e939 | 2015-01-22 20:00:06 +0000 | [diff] [blame] | 29 | libcxx_src_root = getattr(config, 'libcxx_src_root', None) |
| 30 | if not libcxx_src_root: |
| 31 | libcxx_src_root = os.path.join(config.test_source_root, '../../libcxx') |
| 32 | libcxx_test_src_root = os.path.join(libcxx_src_root, 'test') |
| 33 | if os.path.isfile(os.path.join(libcxx_test_src_root, 'libcxx', '__init__.py')): |
| 34 | site.addsitedir(libcxx_test_src_root) |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 35 | else: |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 36 | lit_config.fatal('Could not find libcxx test directory for test imports' |
Eric Fiselier | 9a9e939 | 2015-01-22 20:00:06 +0000 | [diff] [blame] | 37 | ' in: %s' % libcxx_test_src_root) |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 38 | |
Eric Fiselier | 9a9e939 | 2015-01-22 20:00:06 +0000 | [diff] [blame] | 39 | # Infer the test_exec_root from the libcxx_object root. |
Eric Fiselier | 200599c | 2015-02-11 01:07:48 +0000 | [diff] [blame] | 40 | obj_root = getattr(config, 'libcxxabi_obj_root', None) |
Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 41 | |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 42 | # Check that the test exec root is known. |
Eric Fiselier | 9a9e939 | 2015-01-22 20:00:06 +0000 | [diff] [blame] | 43 | if obj_root is None: |
| 44 | import libcxx.test.config |
| 45 | libcxx.test.config.loadSiteConfig( |
| 46 | lit_config, config, 'libcxxabi_site_config', 'LIBCXXABI_SITE_CONFIG') |
| 47 | obj_root = getattr(config, 'libcxxabi_obj_root', None) |
| 48 | if obj_root is None: |
| 49 | import tempfile |
| 50 | obj_root = tempfile.mkdtemp(prefix='libcxxabi-testsuite-') |
| 51 | lit_config.warning('Creating temporary directory for object root: %s' % |
| 52 | obj_root) |
| 53 | |
| 54 | config.test_exec_root = os.path.join(obj_root, 'test') |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 55 | |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 56 | cfg_variant = getattr(config, 'configuration_variant', 'libcxxabi') |
| 57 | if cfg_variant: |
Logan Chien | 9f08403 | 2016-09-02 13:56:05 +0000 | [diff] [blame] | 58 | lit_config.note('Using configuration variant: %s' % cfg_variant) |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 59 | |
| 60 | # Load the Configuration class from the module name <cfg_variant>.test.config. |
| 61 | config_module_name = '.'.join([cfg_variant, 'test', 'config']) |
| 62 | config_module = __import__(config_module_name, fromlist=['Configuration']) |
| 63 | |
| 64 | configuration = config_module.Configuration(lit_config, config) |
| 65 | configuration.configure() |
Eric Fiselier | 9a9e939 | 2015-01-22 20:00:06 +0000 | [diff] [blame] | 66 | configuration.print_config_info() |
Jonathan Roelofs | ac68492 | 2015-01-21 23:06:22 +0000 | [diff] [blame] | 67 | config.test_format = configuration.get_test_format() |