llvm.org GIT mirror llvm / 8c4c37e
Introduce explicit add_unittest_with_input_files target for tests that use llvm::getInputFileDirectory() Using llvm::getInputFileDirectory() in unit tests is discouraged, so require an explicit opt-in. This way, cmake also writes ~60 fewer unused files to disk. Differential Revision: https://reviews.llvm.org/D52095 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342248 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 1 year, 1 month ago
3 changed file(s) with 14 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
11121112 # API for all shared libaries loaded by this executable.
11131113 target_link_libraries(${test_name} PRIVATE gtest_main gtest ${LLVM_PTHREAD_LIB})
11141114
1115 set(LLVM_UNITTEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1116 configure_file(
1117 ${LLVM_MAIN_SRC_DIR}/unittests/unittest.cfg.in
1118 ${CMAKE_CURRENT_BINARY_DIR}/llvm.srcdir.txt)
1119
11201115 add_dependencies(${test_suite} ${test_name})
11211116 get_target_property(test_suite_folder ${test_suite} FOLDER)
11221117 if (NOT ${test_suite_folder} STREQUAL "NOTFOUND")
11241119 endif ()
11251120 endfunction()
11261121
1122 # Use for test binaries that call llvm::getInputFileDirectory(). Use of this
1123 # is discouraged.
1124 function(add_unittest_with_input_files test_suite test_name)
1125 set(LLVM_UNITTEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1126 configure_file(
1127 ${LLVM_MAIN_SRC_DIR}/unittests/unittest.cfg.in
1128 ${CMAKE_CURRENT_BINARY_DIR}/llvm.srcdir.txt)
1129
1130 add_unittest(${test_suite} ${test_name} ${ARGN})
1131 endfunction()
11271132
11281133 # Generic support for adding a benchmark.
11291134 function(add_benchmark benchmark_name)
22
33 function(add_llvm_unittest test_dirname)
44 add_unittest(UnitTests ${test_dirname} ${ARGN})
5 endfunction()
6 function(add_llvm_unittest_with_input_files test_dirname)
7 add_unittest_with_input_files(UnitTests ${test_dirname} ${ARGN})
58 endfunction()
69
710 add_subdirectory(ADT)
33 DebugInfoPDB
44 )
55
6 add_llvm_unittest(DebugInfoPDBTests
6 add_llvm_unittest_with_input_files(DebugInfoPDBTests
77 HashTableTest.cpp
88 NativeSymbolReuseTest.cpp
99 StringTableBuilderTest.cpp