Dan Albert | aa66357 | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 1 | # -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 2 | # Configuration file for the 'lit' test runner. |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 3 | import os |
Dan Albert | aa66357 | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 4 | import site |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 5 | |
Dan Albert | aa66357 | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 6 | site.addsitedir(os.path.dirname(__file__)) |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 7 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 8 | |
Dan Albert | aa66357 | 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 | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 13 | |
Daniel Dunbar | f5eadcd | 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. |
| 18 | config.suffixes = ['.cpp'] |
| 19 | |
| 20 | # test_source_root: The root path where tests are located. |
| 21 | config.test_source_root = os.path.dirname(__file__) |
| 22 | |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 23 | # Infer the test_exec_root from the libcxx_object root. |
| 24 | libcxx_obj_root = getattr(config, 'libcxx_obj_root', None) |
| 25 | if libcxx_obj_root is not None: |
| 26 | config.test_exec_root = os.path.join(libcxx_obj_root, 'test') |
| 27 | |
| 28 | # Check that the test exec root is known. |
| 29 | if config.test_exec_root is None: |
| 30 | # Otherwise, we haven't loaded the site specific configuration (the user is |
| 31 | # probably trying to run on a test file directly, and either the site |
| 32 | # configuration hasn't been created by the build system, or we are in an |
| 33 | # out-of-tree build situation). |
| 34 | site_cfg = lit_config.params.get('libcxx_site_config', |
| 35 | os.environ.get('LIBCXX_SITE_CONFIG')) |
| 36 | if not site_cfg: |
| 37 | lit_config.warning('No site specific configuration file found!' |
| 38 | ' Running the tests in the default configuration.') |
| 39 | # TODO: Set test_exec_root to a temporary directory where output files |
| 40 | # can be placed. This is needed for ShTest. |
| 41 | elif not os.path.isfile(site_cfg): |
| 42 | lit_config.fatal( |
Dan Albert | aa66357 | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 43 | "Specified site configuration file does not exist: '%s'" % |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 44 | site_cfg) |
| 45 | else: |
| 46 | lit_config.note('using site specific configuration at %s' % site_cfg) |
| 47 | lit_config.load_config(config, site_cfg) |
| 48 | raise SystemExit() |
| 49 | |
Dan Albert | aa66357 | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 50 | cfg_variant = getattr(config, 'configuration_variant', 'libcxx') |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 51 | if cfg_variant: |
Eric Fiselier | 33f50fb | 2015-01-16 21:59:07 +0000 | [diff] [blame^] | 52 | lit_config.note('Using configuration variant: %s' % cfg_variant) |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 53 | |
Dan Albert | aa66357 | 2015-01-09 18:03:29 +0000 | [diff] [blame] | 54 | # Load the Configuration class from the module name <cfg_variant>.test.config. |
| 55 | config_module_name = '.'.join([cfg_variant, 'test', 'config']) |
| 56 | config_module = __import__(config_module_name, fromlist=['Configuration']) |
| 57 | |
| 58 | configuration = config_module.Configuration(lit_config, config) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 59 | configuration.configure() |
| 60 | config.test_format = configuration.get_test_format() |