| # test/Unit/lit.cfg - Configuration for the 'lit' test runner. -*- python -*- |
| # |
| # This source file is part of the Swift.org open source project |
| # |
| # Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors |
| # Licensed under Apache License v2.0 with Runtime Library Exception |
| # |
| # See https://swift.org/LICENSE.txt for license information |
| # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| |
| import os |
| |
| import lit.formats |
| import lit.util |
| |
| ### |
| |
| # Check that the object root is known. |
| swift_obj_root = getattr(config, 'swift_obj_root', None) |
| if swift_obj_root is None: |
| # Check for 'swift_unit_site_config' user parameter, and use that if available. |
| site_cfg = lit_config.params.get('swift_unit_site_config', None) |
| if not site_cfg: |
| base_site_cfg = lit_config.params.get('swift_site_config', None) |
| if base_site_cfg: |
| test_dir = os.path.dirname(base_site_cfg) |
| site_cfg = os.path.join(test_dir, 'Unit', 'lit.site.cfg') |
| |
| if site_cfg and os.path.exists(site_cfg): |
| lit_config.load_config(config, site_cfg) |
| raise SystemExit |
| |
| lit_config.fatal("lit must be pointed at a build folder") |
| |
| ### |
| |
| # name: The name of this test suite. |
| config.name = 'Swift-Unit' |
| |
| # suffixes: A list of file extensions to treat as test files. |
| config.suffixes = [] |
| |
| # excludes: A path component to ignore when discovering tests. |
| # The Swift build system does not generate DWARF symbols in the unittests build |
| # directory. For build systems that do, however, files would be generated with |
| # the test suffix "Tests". These need to be excluded because otherwise |
| # `lit.formats.GoogleTest` tries to execute them. |
| # See http://reviews.llvm.org/D18647 for details. |
| config.excludes = ['DWARF'] |
| |
| # Exclude LongTests directories when not executing long tests. |
| swift_test_subset = lit_config.params.get('swift_test_subset', 'validation') |
| if swift_test_subset in ['primary', 'validation', 'only_validation']: |
| config.excludes += ['LongTests'] |
| elif swift_test_subset == 'all': |
| pass |
| elif swift_test_subset == 'only_long': |
| # FIXME: this doesn't exclude not-long tests from the only_long subset. |
| # Currently those tests are very fast so it doesn't matter much. |
| pass |
| else: |
| lit_config.fatal("Unknown test mode %r" % swift_test_subset) |
| |
| # test_source_root: The root path where tests are located. |
| # test_exec_root: The root path where tests should be run. |
| config.test_exec_root = os.path.join(swift_obj_root, 'unittests') |
| config.test_source_root = config.test_exec_root |
| |
| # testFormat: The test format to use to interpret tests. |
| config.test_format = lit.formats.GoogleTest(config.build_mode, 'Tests') |