Skip to content

Commit a85be58

Browse files
committed
[test] Switch couple of SourceKit tests to INITIALIZE_LLVM
And move this into the constructor since it only needs doing once.
1 parent 3ec4288 commit a85be58

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

unittests/SourceKit/SwiftLang/CursorInfoTest.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "SourceKit/Core/NotificationCenter.h"
1717
#include "SourceKit/Support/Concurrency.h"
1818
#include "SourceKit/SwiftLang/Factory.h"
19+
#include "swift/Basic/LLVMInitialize.h"
1920
#include "llvm/Support/MemoryBuffer.h"
2021
#include "llvm/Support/Path.h"
2122
#include "llvm/Support/TargetSelect.h"
@@ -63,10 +64,6 @@ class CursorInfoTest : public ::testing::Test {
6364
LangSupport &getLang() { return getContext().getSwiftLangSupport(); }
6465

6566
void SetUp() override {
66-
llvm::InitializeAllTargets();
67-
llvm::InitializeAllTargetMCs();
68-
llvm::InitializeAllAsmPrinters();
69-
llvm::InitializeAllAsmParsers();
7067
NumTasks = 0;
7168
}
7269

@@ -76,6 +73,7 @@ class CursorInfoTest : public ::testing::Test {
7673
/*diagnosticDocumentationPath*/ "",
7774
SourceKit::createSwiftLangSupport,
7875
/*dispatchOnMain=*/false)) {
76+
INITIALIZE_LLVM();
7977
// This is avoiding destroying \p SourceKit::Context because another
8078
// thread may be active trying to use it to post notifications.
8179
// FIXME: Use shared_ptr ownership to avoid such issues.

unittests/SourceKit/SwiftLang/EditingTest.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "SourceKit/Core/NotificationCenter.h"
1616
#include "SourceKit/Support/Concurrency.h"
1717
#include "SourceKit/SwiftLang/Factory.h"
18+
#include "swift/Basic/LLVMInitialize.h"
1819
#include "llvm/Support/MemoryBuffer.h"
1920
#include "llvm/Support/Path.h"
2021
#include "llvm/Support/TargetSelect.h"
@@ -121,6 +122,7 @@ class EditTest : public ::testing::Test {
121122

122123
public:
123124
EditTest() {
125+
INITIALIZE_LLVM();
124126
// This is avoiding destroying \p SourceKit::Context because another
125127
// thread may be active trying to use it to post notifications.
126128
// FIXME: Use shared_ptr ownership to avoid such issues.
@@ -141,13 +143,6 @@ class EditTest : public ::testing::Test {
141143

142144
LangSupport &getLang() { return Ctx->getSwiftLangSupport(); }
143145

144-
void SetUp() override {
145-
llvm::InitializeAllTargets();
146-
llvm::InitializeAllTargetMCs();
147-
llvm::InitializeAllAsmPrinters();
148-
llvm::InitializeAllAsmParsers();
149-
}
150-
151146
void addNotificationReceiver(DocumentUpdateNotificationReceiver Receiver) {
152147
Ctx->getNotificationCenter()->addDocumentUpdateNotificationReceiver(Receiver);
153148
}

0 commit comments

Comments
 (0)