Skip to content

Fix assert for external interpreter #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Interpreter/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2718,7 +2718,7 @@
TInterp_t GetInterpreter() { return sInterpreter; }

void UseExternalInterpreter(TInterp_t I) {
assert(sInterpreter && "sInterpreter already in use!");
assert(!sInterpreter && "sInterpreter already in use!");

Check warning on line 2721 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L2721

Added line #L2721 was not covered by tests
sInterpreter = static_cast<compat::Interpreter*>(I);
OwningSInterpreter = false;
}
Expand Down
10 changes: 9 additions & 1 deletion unittests/CppInterOp/InterpreterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ TEST(InterpreterTest, CodeCompletion) {

TEST(InterpreterTest, ExternalInterpreterTest) {

if (llvm::sys::RunningOnValgrind())
GTEST_SKIP() << "XFAIL due to Valgrind report";

#ifdef USE_REPL
llvm::ExitOnError ExitOnErr;
clang::IncrementalCompilerBuilder CB;
Expand All @@ -200,7 +203,12 @@ TEST(InterpreterTest, ExternalInterpreterTest) {
#endif

EXPECT_NE(ExtInterp, nullptr);
Cpp::UseExternalInterpreter(ExtInterp);

#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
#ifndef _WIN32 // Windows seems to fail to die...
EXPECT_DEATH(Cpp::UseExternalInterpreter(ExtInterp), "sInterpreter already in use!");
#endif // _WIN32
#endif
EXPECT_TRUE(Cpp::GetInterpreter()) << "External Interpreter not set";

#ifdef USE_REPL
Expand Down