Skip to content

Commit b90a9db

Browse files
committed
Fix assert for external interpreter
1 parent 74ad637 commit b90a9db

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/Interpreter/CppInterOp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2718,7 +2718,7 @@ namespace Cpp {
27182718
TInterp_t GetInterpreter() { return sInterpreter; }
27192719

27202720
void UseExternalInterpreter(TInterp_t I) {
2721-
assert(sInterpreter && "sInterpreter already in use!");
2721+
assert(!sInterpreter && "sInterpreter already in use!");
27222722
sInterpreter = static_cast<compat::Interpreter*>(I);
27232723
OwningSInterpreter = false;
27242724
}

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ TEST(InterpreterTest, CodeCompletion) {
175175

176176
TEST(InterpreterTest, ExternalInterpreterTest) {
177177

178+
if (llvm::sys::RunningOnValgrind())
179+
GTEST_SKIP() << "XFAIL due to Valgrind report";
180+
178181
#ifdef USE_REPL
179182
llvm::ExitOnError ExitOnErr;
180183
clang::IncrementalCompilerBuilder CB;
@@ -200,7 +203,12 @@ TEST(InterpreterTest, ExternalInterpreterTest) {
200203
#endif
201204

202205
EXPECT_NE(ExtInterp, nullptr);
203-
Cpp::UseExternalInterpreter(ExtInterp);
206+
207+
#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
208+
#ifndef _WIN32 // Windows seems to fail to die...
209+
EXPECT_DEATH(Cpp::UseExternalInterpreter(ExtInterp), "sInterpreter already in use!");
210+
#endif // _WIN32
211+
#endif
204212
EXPECT_TRUE(Cpp::GetInterpreter()) << "External Interpreter not set";
205213

206214
#ifdef USE_REPL

0 commit comments

Comments
 (0)