# -*- Python -*-

import os
import platform
import glob

import lit.formats
import lit.util

# Configuration file for the 'lit' test runner.

# name: The name of this test suite.
config.name = 'LNT'

# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.ShTest()

# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.py', '.shtest']

# excludes: A list of individual files to exclude.
config.excludes = ['__init__.py', 'Inputs', 'SharedInputs']

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(os.path.abspath(__file__))
config.test_exec_root = 'test_run_tmp'

config.target_triple = None

# LNT needs a UTF-8 locale when running in Python 3 mode. Rely on the host
# environment to provide it rather than assume a specific UTF-8 locale is
# present.
config.environment['LANG'] = os.environ['LANG']
# Don't generate .pyc files when running tests.
config.environment['PYTHONDONTWRITEBYTECODE'] = "1"
config.environment['SUDO_CMD'] = ""
config.environment['I'] = ""

src_root = os.path.join(config.test_source_root, '..')
config.substitutions.append(('%src_root', src_root))
config.substitutions.append(('%{src_root}', src_root))
config.substitutions.append(('%{shared_inputs}', os.path.join(
            src_root, 'tests', 'SharedInputs')))
config.substitutions.append(('%{test_exec_root}', config.test_exec_root))

if lit_config.params.get('long', None):
    config.available_features.add('long')

# Enable postgres testing. This requires postgres binaries in PATH.
# (You do not need to start a server, the tests will create ad-hoc instances).
if lit_config.params.get('postgres', None):
    config.available_features.add('postgres')

# Enable MySQL testing. This requires mysqld and mysqladmin binaries in PATH.
# (You do not need to start a server, the tests will create ad-hoc instances).
if lit_config.params.get('mysql', None):
    config.available_features.add('mysql')

# Enable tidylib testing. This requires pytidylib and tidy-html5.
if lit_config.params.get('tidylib', None):
    config.substitutions.append(('%{tidylib}', '--use-tidylib'))
else:
    config.substitutions.append(('%{tidylib}', ''))

config.available_features.add(platform.system())

# Enable coverage.py reporting, assuming the coverage module has been installed
# and sitecustomize.py in the virtualenv has been modified appropriately.
if lit_config.params.get('check-coverage', None):
    config.environment['COVERAGE_PROCESS_START'] = os.path.join(
        os.path.dirname(__file__), ".coveragerc")
