[PATCH] D52095: Introduce explicit add_file_reading_unittest target for tests that use llvm::getInputFileDirectory()
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 14 07:54:32 PDT 2018
thakis created this revision.
thakis added a reviewer: zturner.
Herald added a subscriber: mgorny.
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.
https://reviews.llvm.org/D52095
Files:
cmake/modules/AddLLVM.cmake
unittests/CMakeLists.txt
unittests/DebugInfo/PDB/CMakeLists.txt
Index: unittests/DebugInfo/PDB/CMakeLists.txt
===================================================================
--- unittests/DebugInfo/PDB/CMakeLists.txt
+++ unittests/DebugInfo/PDB/CMakeLists.txt
@@ -4,7 +4,7 @@
DebugInfoPDB
)
-add_llvm_unittest(DebugInfoPDBTests
+add_llvm_file_reading_unittest(DebugInfoPDBTests
HashTableTest.cpp
NativeSymbolReuseTest.cpp
StringTableBuilderTest.cpp
Index: unittests/CMakeLists.txt
===================================================================
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -4,6 +4,9 @@
function(add_llvm_unittest test_dirname)
add_unittest(UnitTests ${test_dirname} ${ARGN})
endfunction()
+function(add_llvm_file_reading_unittest test_dirname)
+ add_file_reading_unittest(UnitTests ${test_dirname} ${ARGN})
+endfunction()
add_subdirectory(ADT)
add_subdirectory(Analysis)
Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -1113,18 +1113,23 @@
# 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")
set_property(TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder}")
endif ()
endfunction()
+# Use for test binaries that call llvm::getInputFileDirectory(). Use of this
+# is discouraged.
+function(add_file_reading_unittest 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52095.165509.patch
Type: text/x-patch
Size: 2160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180914/fc44688b/attachment.bin>
More information about the llvm-commits
mailing list