llvm.org GIT mirror llvm / 2462b02
[lit] Add a test for the builtin config map. Config map is not exposed through the command line, so testing this is somewhat tricky. But basically we need a test that if a custom driver builds a config map and passes it to main, it gets respected. A config map allows config files in the source tree to be mapped to alternate config files in the build tree. This particular test works by having two config files in separate directories, and setting up a config map to have that redirects A/lit.site.cfg to B/altconfig. Then, we print a message in A/lit.site.cfg and B/altconfig and check that we do see the output from B but don't see the output from A. Additionally we test that the test suite specified by A's config map is properly discovered. Differential Revision: https://reviews.llvm.org/D38105 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313887 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
10 changed file(s) with 64 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
11121112 # common variables that any Lit instance is likely to need, and custom
11131113 # variables can be passed in.
11141114 function(configure_lit_site_cfg site_in site_out)
1115 cmake_parse_arguments(ARG "" "" "MAIN_CONFIG" ${ARGN})
1115 cmake_parse_arguments(ARG "" "" "MAIN_CONFIG;OUTPUT_MAPPING" ${ARGN})
11161116
11171117 if ("${ARG_MAIN_CONFIG}" STREQUAL "")
1118 set(ARG_MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg")
1118 get_filename_component(INPUT_DIR ${site_in} DIRECTORY)
1119 set(ARG_MAIN_CONFIG "${INPUT_DIR}/lit.cfg")
1120 endif()
1121 if ("${ARG_OUTPUT_MAPPING}" STREQUAL "")
1122 set(ARG_OUTPUT_MAPPING "${site_out}")
11191123 endif()
11201124
11211125 foreach(c ${LLVM_TARGETS_TO_BUILD})
11831187 "lit.llvm.initialize(lit_config, config)\n")
11841188
11851189 configure_file(${site_in} ${site_out} @ONLY)
1186 get_filename_component(INPUT_DIR ${site_in} DIRECTORY)
11871190 if (EXISTS "${ARG_MAIN_CONFIG}")
11881191 set(PYTHON_STATEMENT "map_config('${ARG_MAIN_CONFIG}', '${site_out}')")
11891192 get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP)
0 # The configured file is not placed in the correct location
11 # until the tests are run as we need to copy it into
22 # a copy of the tests folder
3 configure_lit_site_cfg("tests/lit.site.cfg.in" "lit.site.cfg")
3 configure_lit_site_cfg(
4 "${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in"
5 "${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg"
6 OUTPUT_MAPPING
7 "${CMAKE_CURRENT_BINARY_DIR}/tests/lit.site.cfg"
8 )
49
510 # Lit's test suite creates output files next to the sources which makes the
611 # source tree dirty. This is undesirable because we do out of source builds.
77 import subprocess
88 import sys
99 import threading
10
11 def norm_path(path):
12 path = os.path.realpath(path)
13 path = os.path.normpath(path)
14 path = os.path.normcase(path)
15 return path
1016
1117 def is_string(value):
1218 try:
0 import lit.util
1 import os
2 import sys
3
4 main_config = sys.argv[1]
5
6 config_map = {lit.util.norm_path(main_config) : sys.argv[2]}
7 builtin_parameters = {'config_map' : config_map}
8
9 if __name__=='__main__':
10 from lit.main import main
11 main_config_dir = os.path.dirname(main_config)
12 sys.argv = [sys.argv[0]] + sys.argv[3:] + [main_config_dir]
13 main(builtin_parameters)
0 import lit.formats
1 import lit.util
2 config.name = 'config-map'
3 config.suffixes = ['.txt']
4 config.test_format = lit.formats.ShTest()
5
6 import os
7 config.test_exec_root = lit.util.norm_path(os.path.dirname(__file__))
8 config.test_source_root = os.path.join(config.test_exec_root, "tests")
2323 # CHECK-BASIC-OUT: top-level-suite :: subdir/test-three
2424 # CHECK-BASIC-OUT: top-level-suite :: test-one
2525 # CHECK-BASIC-OUT: top-level-suite :: test-two
26
27 # Check discovery when providing the special builtin 'config_map'
28 # RUN: %{python} %{inputs}/config-map-discovery/driver.py \
29 # RUN: %{inputs}/config-map-discovery/main-config/lit.cfg \
30 # RUN: %{inputs}/config-map-discovery/lit.alt.cfg \
31 # RUN: --single-process --debug --show-tests --show-suites > %t.out 2> %t.err
32 # RUN: FileCheck --check-prefix=CHECK-CONFIG-MAP-OUT < %t.out %s
33 # RUN: FileCheck --check-prefix=CHECK-CONFIG-MAP-ERR < %t.err %s
34
35 # CHECK-CONFIG-MAP-OUT-NOT: ERROR: lit.cfg invoked
36 # CHECK-CONFIG-MAP-OUT: -- Test Suites --
37 # CHECK-CONFIG-MAP-OUT: config-map - 2 tests
38 # CHECK-CONFIG-MAP-OUT: Source Root: {{.*[/\\]config-map-discovery[/\\]tests}}
39 # CHECK-CONFIG-MAP-OUT: Exec Root : {{.*[/\\]tests[/\\]inputs[/\\]config-map-discovery}}
40 # CHECK-CONFIG-MAP-OUT: -- Available Tests --
41 # CHECK-CONFIG-MAP-OUT-NOT: invalid-test.txt
42 # CHECK-CONFIG-MAP-OUT: config-map :: test1.txt
43 # CHECK-CONFIG-MAP-OUT: config-map :: test2.txt
44
45 # CHECK-CONFIG-MAP-ERR: loading suite config '{{.*}}lit.alt.cfg'
46 # CHECK-CONFIG-MAP-ERR: loaded config '{{.*}}lit.alt.cfg'
47 # CHECK-CONFIG-MAP-ERR: resolved input '{{.*config-map-discovery[/\\]main-config}}' to 'config-map'::()
2648
2749
2850 # Check discovery when exact test names are given.