Alexey Samsonov | 7274ff8 | 2012-07-31 15:43:11 +0000 | [diff] [blame^] | 1 | # -*- Python -*- |
| 2 | |
| 3 | # Configuration file for 'lit' test runner. |
| 4 | # This file contains common rules for various compiler-rt testsuites. |
| 5 | # It is mostly copied from lit.cfg used by Clang. |
| 6 | import os |
| 7 | import platform |
| 8 | |
| 9 | # Setup test format |
| 10 | execute_external = (platform.system() != 'Windows' |
| 11 | or lit.getBashPath() not in [None, ""]) |
| 12 | config.test_format = lit.formats.ShTest(execute_external) |
| 13 | |
| 14 | # Setup clang binary. |
| 15 | clang_path = getattr(config, 'clang', None) |
| 16 | if (not clang_path) or (not os.path.exists(clang_path)): |
| 17 | lit.fatal("Can't find Clang on path %r" % clang_path) |
| 18 | if not lit.quiet: |
| 19 | lit.note("using clang: %r" % clang_path) |
| 20 | |
| 21 | # Clear some environment variables that might affect Clang. |
| 22 | possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS', |
| 23 | 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', |
| 24 | 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', |
| 25 | 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', |
| 26 | 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING', |
| 27 | 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX', |
| 28 | 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS', |
| 29 | 'LIBCLANG_RESOURCE_USAGE', |
| 30 | 'LIBCLANG_CODE_COMPLETION_LOGGING'] |
| 31 | # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. |
| 32 | if platform.system() != 'Windows': |
| 33 | possibly_dangerous_env_vars.append('INCLUDE') |
| 34 | for name in possibly_dangerous_env_vars: |
| 35 | if name in config.environment: |
| 36 | del config.environment[name] |
| 37 | |
| 38 | # Define %clang substitution to use in test RUN lines. |
| 39 | config.substitutions.append( ("%clang ", (" " + config.clang + " ")) ) |
| 40 | |
| 41 | # Use ugly construction to explicitly prohibit "clang", "clang++" etc. |
| 42 | # in RUN lines. |
| 43 | config.substitutions.append( |
| 44 | (' clang', """\n\n*** Do not use 'clangXXX' in tests, |
| 45 | instead define '%clangXXX' substitution in lit config. ***\n\n""") ) |