File tree Expand file tree Collapse file tree 4 files changed +30
-1
lines changed
include/clang/Interpreter Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,9 @@ namespace Cpp {
117117 }
118118 };
119119
120+ // /\returns the version string information of the library.
121+ std::string GetVersion ();
122+
120123 // / Enables or disables the debugging printouts on stderr.
121124 // / Debugging output can be enabled also by the environment variable
122125 // / CPPINTEROP_EXTRA_INTERPRETER_ARGS. For example,
Original file line number Diff line number Diff line change @@ -115,6 +115,19 @@ namespace Cpp {
115115
116116#undef DEBUG_TYPE
117117
118+ std::string GetVersion () {
119+ const char * const VERSION = " 1.0~dev" ;
120+ std::string fullVersion = " CppInterOp version" ;
121+ fullVersion += VERSION;
122+ fullVersion += " \n (based on "
123+ #ifdef USE_CLING
124+ " cling " ;
125+ #else
126+ " clang-repl" ;
127+ #endif // USE_CLING
128+ return fullVersion + " [" + clang::getClangFullVersion () + " ])\n " ;
129+ }
130+
118131 void EnableDebugOutput (bool value/* =true*/ ) {
119132 llvm::DebugFlag = value;
120133 }
Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ if (NOT TARGET gtest)
77 include (GoogleTest)
88endif ()
99
10+ set (gtest_libs gtest gtest_main)
11+ # Clang prior than clang13 (I think) merges both gmock into gtest.
12+ if (TARGET gmock)
13+ list (APPEND gtest_libs gmock gmock_main)
14+ endif ()
15+
1016add_custom_target (CppInterOpUnitTests)
1117set_target_properties (CppInterOpUnitTests PROPERTIES FOLDER "CppInterOp tests" )
1218add_dependencies (CppInterOpUnitTests clangCppInterOp)
@@ -18,7 +24,7 @@ function(add_cppinterop_unittest name)
1824 target_include_directories (${name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${GTEST_INCLUDE_DIR} )
1925 set_property (TARGET ${name} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
2026
21- target_link_libraries (${name} PUBLIC ${ARG_LIBRARIES} gtest gtest_main pthread)
27+ target_link_libraries (${name} PUBLIC ${ARG_LIBRARIES} ${gtest_libs} pthread)
2228
2329 add_test (NAME cppinterop-${name} COMMAND ${name} )
2430 set_tests_properties (cppinterop-${name} PROPERTIES
Original file line number Diff line number Diff line change 11#include " clang/Interpreter/CppInterOp.h"
22
3+ #include < gmock/gmock.h>
34#include " gtest/gtest.h"
45
6+ using ::testing::StartsWith;
7+
8+ TEST (InterpreterTest, Version) {
9+ EXPECT_THAT (Cpp::GetVersion (), StartsWith (" CppInterOp version" ));
10+ }
11+
512TEST (InterpreterTest, DebugFlag) {
613 EXPECT_FALSE (Cpp::IsDebugOutputEnabled ());
714 std::string cerrs;
You can’t perform that action at this time.
0 commit comments