| # -*- 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++abi' |
| |
| # 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 libcxx_test_source_root for configuration import. |
| # If libcxx_source_root isn't specified in the config, assume that the libcxx |
| # and libcxxabi source directories are sibling directories. |
| libcxx_source_root = getattr(config, 'libcxx_source_root', |
| os.path.join(config.test_source_root, |
| '../../libcxx')) |
| libcxx_test_source_root = os.path.join(libcxx_source_root, 'test') |
| if os.path.isdir(libcxx_test_source_root): |
| sys.path.insert(0, libcxx_test_source_root) |
| else: |
| lit_config.fatal('Could not find libcxx test directory for test imports' |
| ' in: %s' % libcxx_test_source_root) |
| |
| # Infer the test_exec_root from the libcxxabi_object root. |
| libcxxabi_obj_root = getattr(config, 'libcxxabi_obj_root', None) |
| if libcxxabi_obj_root is not None: |
| config.test_exec_root = os.path.join(libcxxabi_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('libcxxabi_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', 'libcxxabi') |
| 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() |