blob: c487cf36d3cd7264ed5f43f821a67ee72efcded4 [file] [log] [blame]
Dan Albertaa663572015-01-09 18:03:29 +00001# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
Daniel Dunbarf5eadcd2010-09-15 03:57:04 +00002# Configuration file for the 'lit' test runner.
Daniel Dunbarf5eadcd2010-09-15 03:57:04 +00003import os
Dan Albertaa663572015-01-09 18:03:29 +00004import site
Daniel Dunbarf5eadcd2010-09-15 03:57:04 +00005
Dan Albertaa663572015-01-09 18:03:29 +00006site.addsitedir(os.path.dirname(__file__))
Daniel Dunbarf5eadcd2010-09-15 03:57:04 +00007
Dan Albert2c262132014-08-21 17:30:44 +00008
Dan Albertaa663572015-01-09 18:03:29 +00009# Tell pylint that we know config and lit_config exist somewhere.
10if 'PYLINT_IMPORT' in os.environ:
11 config = object()
12 lit_config = object()
Dan Albert2c262132014-08-21 17:30:44 +000013
Daniel Dunbarf5eadcd2010-09-15 03:57:04 +000014# name: The name of this test suite.
15config.name = 'libc++'
16
17# suffixes: A list of file extensions to treat as test files.
18config.suffixes = ['.cpp']
19
20# test_source_root: The root path where tests are located.
21config.test_source_root = os.path.dirname(__file__)
22
Eric Fiselier4778eed2014-12-20 03:16:55 +000023# Infer the test_exec_root from the libcxx_object root.
24libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
25if 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.
29if 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 Albertaa663572015-01-09 18:03:29 +000043 "Specified site configuration file does not exist: '%s'" %
Eric Fiselier4778eed2014-12-20 03:16:55 +000044 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 Albertaa663572015-01-09 18:03:29 +000050cfg_variant = getattr(config, 'configuration_variant', 'libcxx')
Dan Albert877409a2014-11-24 22:24:06 +000051if cfg_variant:
Eric Fiselier33f50fb2015-01-16 21:59:07 +000052 lit_config.note('Using configuration variant: %s' % cfg_variant)
Dan Albert877409a2014-11-24 22:24:06 +000053
Dan Albertaa663572015-01-09 18:03:29 +000054# Load the Configuration class from the module name <cfg_variant>.test.config.
55config_module_name = '.'.join([cfg_variant, 'test', 'config'])
56config_module = __import__(config_module_name, fromlist=['Configuration'])
57
58configuration = config_module.Configuration(lit_config, config)
Dan Albert2c262132014-08-21 17:30:44 +000059configuration.configure()
60config.test_format = configuration.get_test_format()