blob: 29d1a3b72854e84d2a174832280a8609892736dc [file] [log] [blame]
Jonathan Roelofsac684922015-01-21 23:06:22 +00001# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
Dan Albertfd961bd2014-07-10 02:20:11 +00002
3# Configuration file for the 'lit' test runner.
4
Jonathan Roelofsac684922015-01-21 23:06:22 +00005
Dan Albertfd961bd2014-07-10 02:20:11 +00006import os
Jonathan Roelofsac684922015-01-21 23:06:22 +00007import site
Dan Albertfd961bd2014-07-10 02:20:11 +00008
Jonathan Roelofsac684922015-01-21 23:06:22 +00009site.addsitedir(os.path.dirname(__file__))
Dan Albertfd961bd2014-07-10 02:20:11 +000010
Dan Albertfd961bd2014-07-10 02:20:11 +000011
Jonathan Roelofsac684922015-01-21 23:06:22 +000012# Tell pylint that we know config and lit_config exist somewhere.
13if 'PYLINT_IMPORT' in os.environ:
14 config = object()
15 lit_config = object()
Dan Albertfd961bd2014-07-10 02:20:11 +000016
17# name: The name of this test suite.
18config.name = 'libc++abi'
19
20# suffixes: A list of file extensions to treat as test files.
Logan Chiencc4f5122016-11-13 14:44:41 +000021config.suffixes = ['.cpp', '.s']
Dan Albertfd961bd2014-07-10 02:20:11 +000022
23# test_source_root: The root path where tests are located.
24config.test_source_root = os.path.dirname(__file__)
25
Jonathan Roelofsac684922015-01-21 23:06:22 +000026# 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 Fiselier9a9e9392015-01-22 20:00:06 +000029libcxx_src_root = getattr(config, 'libcxx_src_root', None)
30if not libcxx_src_root:
31 libcxx_src_root = os.path.join(config.test_source_root, '../../libcxx')
32libcxx_test_src_root = os.path.join(libcxx_src_root, 'test')
33if os.path.isfile(os.path.join(libcxx_test_src_root, 'libcxx', '__init__.py')):
34 site.addsitedir(libcxx_test_src_root)
Dan Albertfd961bd2014-07-10 02:20:11 +000035else:
Jonathan Roelofsac684922015-01-21 23:06:22 +000036 lit_config.fatal('Could not find libcxx test directory for test imports'
Eric Fiselier9a9e9392015-01-22 20:00:06 +000037 ' in: %s' % libcxx_test_src_root)
Dan Albertfd961bd2014-07-10 02:20:11 +000038
Eric Fiselier9a9e9392015-01-22 20:00:06 +000039# Infer the test_exec_root from the libcxx_object root.
Eric Fiselier200599c2015-02-11 01:07:48 +000040obj_root = getattr(config, 'libcxxabi_obj_root', None)
Dan Albertefa37d12014-12-18 00:03:57 +000041
Jonathan Roelofsac684922015-01-21 23:06:22 +000042# Check that the test exec root is known.
Eric Fiselier9a9e9392015-01-22 20:00:06 +000043if 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
54config.test_exec_root = os.path.join(obj_root, 'test')
Dan Albertfd961bd2014-07-10 02:20:11 +000055
Jonathan Roelofsac684922015-01-21 23:06:22 +000056cfg_variant = getattr(config, 'configuration_variant', 'libcxxabi')
57if cfg_variant:
Logan Chien9f084032016-09-02 13:56:05 +000058 lit_config.note('Using configuration variant: %s' % cfg_variant)
Jonathan Roelofsac684922015-01-21 23:06:22 +000059
60# Load the Configuration class from the module name <cfg_variant>.test.config.
61config_module_name = '.'.join([cfg_variant, 'test', 'config'])
62config_module = __import__(config_module_name, fromlist=['Configuration'])
63
64configuration = config_module.Configuration(lit_config, config)
65configuration.configure()
Eric Fiselier9a9e9392015-01-22 20:00:06 +000066configuration.print_config_info()
Jonathan Roelofsac684922015-01-21 23:06:22 +000067config.test_format = configuration.get_test_format()