[llvm] r342248 - Introduce explicit add_unittest_with_input_files target for tests that use llvm::getInputFileDirectory()
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 14 10:34:46 PDT 2018
Author: nico
Date: Fri Sep 14 10:34:46 2018
New Revision: 342248
URL: http://llvm.org/viewvc/llvm-project?rev=342248&view=rev
Log:
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
Modified:
llvm/trunk/cmake/modules/AddLLVM.cmake
llvm/trunk/unittests/CMakeLists.txt
llvm/trunk/unittests/DebugInfo/PDB/CMakeLists.txt
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=342248&r1=342247&r2=342248&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Fri Sep 14 10:34:46 2018
@@ -1113,11 +1113,6 @@ function(add_unittest test_suite test_na
# API for all shared libaries loaded by this executable.
target_link_libraries(${test_name} PRIVATE gtest_main gtest ${LLVM_PTHREAD_LIB})
- set(LLVM_UNITTEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
- configure_file(
- ${LLVM_MAIN_SRC_DIR}/unittests/unittest.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/llvm.srcdir.txt)
-
add_dependencies(${test_suite} ${test_name})
get_target_property(test_suite_folder ${test_suite} FOLDER)
if (NOT ${test_suite_folder} STREQUAL "NOTFOUND")
@@ -1125,6 +1120,16 @@ function(add_unittest test_suite test_na
endif ()
endfunction()
+# Use for test binaries that call llvm::getInputFileDirectory(). Use of this
+# is discouraged.
+function(add_unittest_with_input_files test_suite test_name)
+ set(LLVM_UNITTEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ configure_file(
+ ${LLVM_MAIN_SRC_DIR}/unittests/unittest.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/llvm.srcdir.txt)
+
+ add_unittest(${test_suite} ${test_name} ${ARGN})
+endfunction()
# Generic support for adding a benchmark.
function(add_benchmark benchmark_name)
Modified: llvm/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=342248&r1=342247&r2=342248&view=diff
==============================================================================
--- llvm/trunk/unittests/CMakeLists.txt (original)
+++ llvm/trunk/unittests/CMakeLists.txt Fri Sep 14 10:34:46 2018
@@ -4,6 +4,9 @@ set_target_properties(UnitTests PROPERTI
function(add_llvm_unittest test_dirname)
add_unittest(UnitTests ${test_dirname} ${ARGN})
endfunction()
+function(add_llvm_unittest_with_input_files test_dirname)
+ add_unittest_with_input_files(UnitTests ${test_dirname} ${ARGN})
+endfunction()
add_subdirectory(ADT)
add_subdirectory(Analysis)
Modified: llvm/trunk/unittests/DebugInfo/PDB/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/CMakeLists.txt?rev=342248&r1=342247&r2=342248&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/CMakeLists.txt (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/CMakeLists.txt Fri Sep 14 10:34:46 2018
@@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS
DebugInfoPDB
)
-add_llvm_unittest(DebugInfoPDBTests
+add_llvm_unittest_with_input_files(DebugInfoPDBTests
HashTableTest.cpp
NativeSymbolReuseTest.cpp
StringTableBuilderTest.cpp
More information about the llvm-commits
mailing list