mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-11-27 05:40:48 +00:00
aa66357f48
Summary: I've moved the bulk of `lit.cfg` into `test/libcxx/testconfig.py` and `test/libcxx/testformat.py`. All that remains in `lit.cfg` is the logic to discover lit.site.cfg if lit.cfg was run directly, and the logic for loading configuration variants. The configuration variant flow has changed with this patch. Rather than instantiating an object of type `<VARIANT>Configuration`, we now instatiate an object of type `Configuration` that was loaded from the module `<VARIANT>.testconfig.py`. This has to be done on a per-project basis rather than in LIT itself because LIT doesn't actually know where the real test directory is, only where the site configuration is (which is usually in the output directory). It's simple enough to do though, so it's fine to require each project to do it themselves. I also cleaned up all the pylint issues while I was here, which was mostly just a matter of fixing long lines. Reviewers: mclow.lists, jroelofs, EricWF Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6881 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@225532 91177308-0d34-0410-b5e6-96231b3b80d8
61 lines
2.4 KiB
Python
61 lines
2.4 KiB
Python
# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
|
|
# Configuration file for the 'lit' test runner.
|
|
import os
|
|
import site
|
|
|
|
site.addsitedir(os.path.dirname(__file__))
|
|
|
|
|
|
# Tell pylint that we know config and lit_config exist somewhere.
|
|
if 'PYLINT_IMPORT' in os.environ:
|
|
config = object()
|
|
lit_config = object()
|
|
|
|
# name: The name of this test suite.
|
|
config.name = 'libc++'
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
|
config.suffixes = ['.cpp']
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
# Infer the test_exec_root from the libcxx_object root.
|
|
libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
|
|
if libcxx_obj_root is not None:
|
|
config.test_exec_root = os.path.join(libcxx_obj_root, 'test')
|
|
|
|
# Check that the test exec root is known.
|
|
if config.test_exec_root is None:
|
|
# Otherwise, we haven't loaded the site specific configuration (the user is
|
|
# probably trying to run on a test file directly, and either the site
|
|
# configuration hasn't been created by the build system, or we are in an
|
|
# out-of-tree build situation).
|
|
site_cfg = lit_config.params.get('libcxx_site_config',
|
|
os.environ.get('LIBCXX_SITE_CONFIG'))
|
|
if not site_cfg:
|
|
lit_config.warning('No site specific configuration file found!'
|
|
' Running the tests in the default configuration.')
|
|
# TODO: Set test_exec_root to a temporary directory where output files
|
|
# can be placed. This is needed for ShTest.
|
|
elif not os.path.isfile(site_cfg):
|
|
lit_config.fatal(
|
|
"Specified site configuration file does not exist: '%s'" %
|
|
site_cfg)
|
|
else:
|
|
lit_config.note('using site specific configuration at %s' % site_cfg)
|
|
lit_config.load_config(config, site_cfg)
|
|
raise SystemExit()
|
|
|
|
cfg_variant = getattr(config, 'configuration_variant', 'libcxx')
|
|
if cfg_variant:
|
|
print 'Using configuration variant: %s' % cfg_variant
|
|
|
|
# Load the Configuration class from the module name <cfg_variant>.test.config.
|
|
config_module_name = '.'.join([cfg_variant, 'test', 'config'])
|
|
config_module = __import__(config_module_name, fromlist=['Configuration'])
|
|
|
|
configuration = config_module.Configuration(lit_config, config)
|
|
configuration.configure()
|
|
config.test_format = configuration.get_test_format()
|