Skip to content

Commit b804eef

Browse files
committed
[clangd] Move clangd tests to clangd directory. check-clangd is no longer part of check-clang-tools.
Summary: Motivation: - this layout is a pain to work with - without a common root, it's painful to express things like "disable clangd" (D61122) - CMake/lit configs are a maintenance hazard, and the more the one-off hacks for various tools are entangled, the more we see apathy and non-ownership. This attempts to use the bare-minimum configuration needed (while still supporting the difficult cases: windows, standalone clang build, dynamic libs). In particular the lit.cfg.py and lit.site.cfg.py.in are merged into lit.cfg.in. The logic in these files is now minimal. (Much of clang-tools-extra's lit configs can probably be cleaned up by reusing lit.llvm.llvm_config.use_clang(), and every llvm project does its own version of LDPATH mangling. I haven't attempted to fix any of those). Docs are still in clang-tools-extra/docs, I don't have any plans to touch those. Reviewers: gribozavr Subscribers: mgorny, javed.absar, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits, ilya-biryukov, thakis Tags: #clang Differential Revision: https://reviews.llvm.org/D61187 llvm-svn: 359424
1 parent e62915b commit b804eef

File tree

112 files changed

+119
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+119
-58
lines changed

clang-tools-extra/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
if (NOT DEFINED CLANGD_BUILD_XPC)
2-
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
3-
set(CLANGD_BUILD_XPC_DEFAULT ON)
4-
else ()
5-
set(CLANGD_BUILD_XPC_DEFAULT OFF)
6-
endif ()
7-
8-
set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC Support For Clangd." FORCE)
9-
10-
unset(CLANGD_BUILD_XPC_DEFAULT)
11-
endif ()
12-
131
add_subdirectory(clang-apply-replacements)
142
add_subdirectory(clang-reorder-fields)
153
add_subdirectory(modularize)

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Configure the Features.inc file.
2-
llvm_canonicalize_cmake_booleans(
3-
CLANGD_BUILD_XPC)
2+
if (NOT DEFINED CLANGD_BUILD_XPC)
3+
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
4+
set(CLANGD_BUILD_XPC_DEFAULT ON)
5+
else ()
6+
set(CLANGD_BUILD_XPC_DEFAULT OFF)
7+
endif ()
8+
9+
set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC Support For Clangd." FORCE)
10+
unset(CLANGD_BUILD_XPC_DEFAULT)
11+
endif ()
12+
13+
llvm_canonicalize_cmake_booleans(CLANGD_BUILD_XPC)
14+
415
configure_file(
516
${CMAKE_CURRENT_SOURCE_DIR}/Features.inc.in
617
${CMAKE_CURRENT_BINARY_DIR}/Features.inc
@@ -130,3 +141,8 @@ endif()
130141
if ( CLANGD_BUILD_XPC )
131142
add_subdirectory(xpc)
132143
endif ()
144+
145+
if(CLANG_INCLUDE_TESTS)
146+
add_subdirectory(test)
147+
add_subdirectory(unittests)
148+
endif()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
set(CLANGD_TEST_DEPS
2+
clangd
3+
ClangdTests
4+
# No tests for these, but we should still make sure they build.
5+
clangd-indexer
6+
dexp
7+
)
8+
9+
if(CLANGD_BUILD_XPC)
10+
list(APPEND CLANGD_TEST_DEPS clangd-xpc-test-client)
11+
endif()
12+
13+
foreach(dep FileCheck count not)
14+
if(TARGET ${dep})
15+
list(APPEND CLANGD_TEST_DEPS ${dep})
16+
endif()
17+
endforeach()
18+
19+
configure_lit_site_cfg(
20+
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.in
21+
${CMAKE_CURRENT_BINARY_DIR}/lit.cfg)
22+
configure_lit_site_cfg(
23+
${CMAKE_CURRENT_SOURCE_DIR}/../unittests/lit.cfg.in
24+
${CMAKE_CURRENT_BINARY_DIR}/../unittests/lit.cfg)
25+
26+
add_lit_testsuite(check-clangd "Running the Clangd regression tests"
27+
${CMAKE_CURRENT_BINARY_DIR}/Unit;${CMAKE_CURRENT_BINARY_DIR}
28+
DEPENDS ${CLANGD_TEST_DEPS})
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@LIT_SITE_CFG_IN_HEADER@
2+
3+
import lit.llvm
4+
import lit.formats
5+
6+
# Reuse clang configuration (PATH setup, etc).
7+
config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
8+
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
9+
config.clang_libs_dir = "@CLANG_LIBS_DIR@"
10+
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
11+
config.target_triple = "@TARGET_TRIPLE@"
12+
config.host_triple = "@LLVM_HOST_TRIPLE@"
13+
lit.llvm.initialize(lit_config, config)
14+
lit.llvm.llvm_config.use_clang()
15+
16+
config.name = 'Clangd'
17+
config.suffixes = ['.test']
18+
config.excludes = ['Inputs']
19+
config.test_format = lit.formats.ShTest(not lit.llvm.llvm_config.use_lit_shell)
20+
config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@"
21+
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
22+
23+
# Clangd-specific lit environment.
24+
config.substitutions.append(('%clangd-benchmark-dir',
25+
"@CMAKE_CURRENT_BINARY_DIR@/../benchmarks"))
26+
27+
if @CLANGD_BUILD_XPC@:
28+
config.available_features.add('clangd-xpc-support')
29+

clang-tools-extra/unittests/clangd/CMakeLists.txt renamed to clang-tools-extra/clangd/unittests/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ include_directories(
1111
${CLANGD_BINARY_DIR}
1212
)
1313

14-
add_extra_unittest(ClangdTests
14+
if(CLANG_BUILT_STANDALONE)
15+
# LLVMTestingSupport library is needed for clangd tests.
16+
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
17+
AND NOT TARGET LLVMTestingSupport)
18+
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
19+
lib/Testing/Support)
20+
endif()
21+
endif()
22+
23+
add_custom_target(ClangdUnitTests)
24+
add_unittest(ClangdUnitTests ClangdTests
1525
Annotations.cpp
1626
BackgroundIndexTests.cpp
1727
CancellationTests.cpp
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@LIT_SITE_CFG_IN_HEADER@
2+
# This is a shim to run the gtest unittests in ../unittests using lit.
3+
4+
import lit.formats
5+
config.name = "Clangd Unit Tests"
6+
config.test_format = lit.formats.GoogleTest('.', 'Tests')
7+
config.test_source_root = "@CMAKE_CURRENT_BINARY_DIR@"
8+
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
9+
10+
# Point the dynamic loader at dynamic libraries in 'lib'.
11+
# XXX: it seems every project has a copy of this logic. Move it somewhere.
12+
import platform
13+
if platform.system() == 'Darwin':
14+
shlibpath_var = 'DYLD_LIBRARY_PATH'
15+
elif platform.system() == 'Windows':
16+
shlibpath_var = 'PATH'
17+
else:
18+
shlibpath_var = 'LD_LIBRARY_PATH'
19+
config.environment[shlibpath_var] = os.path.pathsep.join((
20+
"@SHLIBDIR@", "@LLVM_LIBS_DIR@",
21+
config.environment.get(shlibpath_var,'')))
22+
23+

clang-tools-extra/test/CMakeLists.txt

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ endif ()
1515

1616
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
1717

18-
llvm_canonicalize_cmake_booleans(
19-
CLANG_ENABLE_STATIC_ANALYZER
20-
CLANGD_BUILD_XPC)
18+
llvm_canonicalize_cmake_booleans(CLANG_ENABLE_STATIC_ANALYZER)
2119

2220
configure_lit_site_cfg(
2321
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
@@ -70,19 +68,6 @@ set(CLANG_TOOLS_TEST_DEPS
7068
clang
7169
)
7270

73-
if(CLANGD_BUILD_XPC)
74-
list(APPEND CLANG_TOOLS_TEST_DEPS clangd-xpc-test-client)
75-
endif()
76-
77-
set(CLANGD_TEST_DEPS
78-
clangd
79-
ClangdTests
80-
# clangd-related tools which don't have tests, add them to the test to make
81-
# sure we don't introduce new changes that break their compilations.
82-
clangd-indexer
83-
dexp
84-
)
85-
8671
# Add lit test dependencies.
8772
set(LLVM_UTILS_DEPS
8873
FileCheck count not
@@ -93,27 +78,10 @@ foreach(dep ${LLVM_UTILS_DEPS})
9378
endif()
9479
endforeach()
9580

96-
foreach(clangd_dep ${CLANGD_TEST_DEPS})
97-
list(APPEND CLANG_TOOLS_TEST_DEPS
98-
${clangd_dep})
99-
endforeach()
100-
10181
add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
10282
${CMAKE_CURRENT_BINARY_DIR}
10383
DEPENDS ${CLANG_TOOLS_TEST_DEPS}
10484
ARGS ${CLANG_TOOLS_TEST_EXTRA_ARGS}
10585
)
10686

10787
set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
108-
109-
# Setup an individual test for building and testing clangd-only stuff.
110-
# Note: all clangd tests have been covered in check-clang-tools, this is a
111-
# convenient target for clangd developers.
112-
# Exclude check-clangd from check-all.
113-
set(EXCLUDE_FROM_ALL ON)
114-
add_lit_testsuite(check-clangd "Running the Clangd regression tests"
115-
${CMAKE_CURRENT_BINARY_DIR}/Unit/clangd;${CMAKE_CURRENT_BINARY_DIR}/clangd
116-
DEPENDS ${CLANGD_TEST_DEPS}
117-
)
118-
set_target_properties(check-clangd PROPERTIES FOLDER "Clangd tests")
119-
set(EXCLUDE_FROM_ALL OFF)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@LIT_SITE_CFG_IN_HEADER@
2+
3+
config.extra_tools_obj_dir = "@CLANG_TOOLS_BINARY_DIR@/unittests"
4+
config.extra_tools_src_dir = "@CLANG_TOOLS_SOURCE_DIR@/unittests"
5+
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
6+
config.shlibdir = "@SHLIBDIR@"
7+
config.target_triple = "@TARGET_TRIPLE@"
8+
9+
lit_config.load_config(config, "@CLANG_TOOLS_SOURCE_DIR@/test/Unit/lit.cfg.py")

clang-tools-extra/unittests/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,10 @@ function(add_extra_unittest test_dirname)
55
add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
66
endfunction()
77

8-
if(CLANG_BUILT_STANDALONE)
9-
# LLVMTestingSupport library is needed for clangd tests.
10-
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
11-
AND NOT TARGET LLVMTestingSupport)
12-
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
13-
lib/Testing/Support)
14-
endif()
15-
endif()
16-
178
add_subdirectory(clang-apply-replacements)
189
add_subdirectory(clang-change-namespace)
1910
add_subdirectory(clang-doc)
2011
add_subdirectory(clang-include-fixer)
2112
add_subdirectory(clang-move)
2213
add_subdirectory(clang-query)
2314
add_subdirectory(clang-tidy)
24-
add_subdirectory(clangd)

0 commit comments

Comments
 (0)