Skip to content

Commit 148b64e

Browse files
committed
Simplify feature module registry test
1 parent 0919190 commit 148b64e

File tree

6 files changed

+27
-75
lines changed

6 files changed

+27
-75
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ target_include_directories(ClangdTests PUBLIC
155155
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
156156
)
157157

158-
add_subdirectory(feature-modules)
159-
160158
clang_target_link_libraries(ClangdTests
161159
PRIVATE
162160
clangAST
@@ -186,8 +184,6 @@ target_link_libraries(ClangdTests
186184
clangTidy
187185
clangTidyUtils
188186
clangdSupport
189-
190-
${FEATURE_MODULES}
191187
)
192188

193189
if (CLANGD_ENABLE_REMOTE)

clang-tools-extra/clangd/unittests/FeatureModulesRegistryTests.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "FeatureModule.h"
10-
#include "feature-modules/ForceLinker.h" // IWYU pragma: keep
1110
#include "refactor/Tweak.h"
11+
#include "support/Logger.h"
1212

1313
#include "gmock/gmock.h"
1414
#include "gtest/gtest.h"
@@ -49,9 +49,35 @@ raw_ostream &operator<<(raw_ostream &OS, const clang::clangd::Tweak &T) {
4949
namespace clang::clangd {
5050
namespace {
5151

52+
class Dummy final : public FeatureModule {
53+
static constexpr const char *TweakID = "DummyTweak";
54+
struct DummyTweak final : public Tweak {
55+
const char *id() const override { return TweakID; }
56+
bool prepare(const Selection &) override { return true; }
57+
Expected<Effect> apply(const Selection &) override {
58+
return error("not implemented");
59+
}
60+
std::string title() const override { return id(); }
61+
llvm::StringLiteral kind() const override {
62+
return llvm::StringLiteral("");
63+
};
64+
};
65+
66+
void contributeTweaks(std::vector<std::unique_ptr<Tweak>> &Out) override {
67+
Out.emplace_back(new DummyTweak);
68+
}
69+
};
70+
71+
static FeatureModuleRegistry::Add<Dummy>
72+
X("dummy", "Dummy feature module with dummy tweak");
73+
5274
MATCHER_P(moduleName, Name, "") { return arg.getName() == Name; }
5375
MATCHER_P(tweakID, ID, "") { return arg->id() == llvm::StringRef(ID); }
5476

77+
// In this test, it is assumed that for unittests executable, all feature
78+
// modules are added to the registry only here (in this file). To implement
79+
// modules for clangd tool, one need to link them directly to the clangd
80+
// executable in clangd/tool/CMakeLists.txt.
5581
TEST(FeatureModulesRegistryTest, DummyModule) {
5682
EXPECT_THAT(FeatureModuleRegistry::entries(),
5783
ElementsAre(moduleName("dummy")));

clang-tools-extra/clangd/unittests/feature-modules/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

clang-tools-extra/clangd/unittests/feature-modules/ForceLinker.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

clang-tools-extra/clangd/unittests/feature-modules/dummy/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

clang-tools-extra/clangd/unittests/feature-modules/dummy/DummyFeatureModule.cpp

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)