# -*- Python -*-

# Configuration file for the 'lit' test runner.

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

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

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

# Get the base build directory for the android source tree from environment.
config.base_path = os.getenv('ANDROID_BUILD_TOP')

# test_source_root: The path where tests are located (default is the test suite
# root).
config.test_source_root = None

# test_exec_root: The path where tests are located (default is the test suite
# root).
config.test_exec_root = os.path.join(config.base_path, 'out', 'tests', 'slang', 'lit-tests')

# target_triple: Used by ShTest and TclTest formats for XFAIL checks.
config.target_triple = 'slang'

def inferTool(binary_name, env_var, PATH):
    # Determine which tool to use.
    tool = os.getenv(env_var)

    # If the user set the overriding environment variable, use it
    if tool and os.path.isfile(tool):
        return tool

    # Otherwise look in the path.
    tool = lit.util.which(binary_name, PATH)

    if not tool:
        lit.fatal("couldn't find " + binary_name + " program in " + PATH + " , try setting "
                  + env_var + " in your environment")

    return os.path.abspath(tool)

config.slang = inferTool('llvm-rs-cc', 'SLANG', os.path.join(config.base_path, 'out', 'host', 'linux-x86', 'bin')).replace('\\', '/')

config.filecheck = inferTool('FileCheck', 'FILECHECK', config.environment['PATH'])
config.rs_filecheck_wrapper = inferTool('rs-filecheck-wrapper.sh', 'RS_FILECHECK_WRAPPER', os.path.join(config.base_path, 'frameworks', 'compile', 'slang', 'lit-tests'))

# Use most up-to-date headers for includes.
config.slang_includes = "-I " + os.path.join(config.base_path, 'frameworks', 'base', 'libs', 'rs', 'scriptc') + " " \
                      + "-I " + os.path.join(config.base_path, 'external', 'clang', 'lib', 'Headers')

config.slang_options = "-emit-llvm -o " + config.test_exec_root \
                     + " -output-dep-dir " + config.test_exec_root \
                     + " -java-reflection-path-base " + config.test_exec_root

if not lit.quiet:
    lit.note('using slang: %r' % config.slang)
    lit.note('using FileCheck: %r' % config.filecheck)
    lit.note('using rs-filecheck-wrapper.sh: %r' % config.rs_filecheck_wrapper)
    lit.note('using output directory: %r' % config.test_exec_root)

# Tools configuration substitutions
config.substitutions.append( ('%Slang', ' ' + config.slang + ' ' + config.slang_includes + ' ' + config.slang_options ) )
config.substitutions.append( ('%rs-filecheck-wrapper', ' ' + config.rs_filecheck_wrapper + ' ' + config.test_exec_root + ' ' + config.filecheck + ' ') )
