You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/01/09 02:59:41 UTC

[GitHub] ShannonDing closed pull request #23: Refactor unittests

ShannonDing closed pull request #23: Refactor unittests
URL: https://github.com/apache/rocketmq-client-python/pull/23
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7df3c84..39d0766 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,9 @@
 #* See the License for the specific language governing permissions and
 #* limitations under the License.
 #*/
+
+project(rocketmq-client-python)
+
 cmake_minimum_required(VERSION 2.6)
 
 set(CMAKE_MACOSX_RPATH 1)
@@ -205,11 +208,10 @@ set(TIME_WITH_SYS_TIME 1)
 set(HAVE_SOCKLEN_T 1)
 
 option(TEST "Build test cases" OFF)
-
 if (TEST)
     enable_testing()
     option(gtest_build_tests OFF)
-    add_subdirectory(third_party/googletest/googletest)
+    #add_subdirectory(third_party/googletest/googletest)
     include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
     add_subdirectory(unitests)
 endif ()
diff --git a/src/PythonWrapper.h b/src/PythonWrapper.h
index 2ad8255..7e66948 100644
--- a/src/PythonWrapper.h
+++ b/src/PythonWrapper.h
@@ -99,6 +99,8 @@ int PySetPushConsumerSessionCredentials(void *consumer, const char *accessKey, c
 
 //push consumer
 int PySetPullConsumerNameServerDomain(void *consumer, const char *domain);
+//version
+const char *PyGetVersion();
 
 #ifdef __cplusplus
 };
diff --git a/third_party/googletest/README.md b/third_party/googletest/README.md
deleted file mode 100644
index 39da329..0000000
--- a/third_party/googletest/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-### Google Test 
-
------------------------
-Download [googletest source](https://github.com/abseil/googletest)
diff --git a/unitests/CMakeLists.txt b/unitests/CMakeLists.txt
index 02004ae..27d264d 100644
--- a/unitests/CMakeLists.txt
+++ b/unitests/CMakeLists.txt
@@ -14,18 +14,57 @@
 #* See the License for the specific language governing permissions and
 #* limitations under the License.
 #*/
+project(UnitTest)
+if (WIN32)
+    find_package(gtest)
+elseif (APPLE)
+    find_package(gtest)
+else ()
+    find_package(gtest)
+endif (WIN32)
 
+if (GTEST_FOUND)
+    message(STATUS "** GTEST Include dir: ${GTEST_INCLUDE_DIRS}")
+    message(STATUS "** GTEST Libraries dir: ${GTEST_LIBRARY_DIRS}")
+    message(STATUS "** GTEST Libraries: ${GTEST_LIBRARIES}")
+    include_directories(${GTEST_INCLUDE_DIRS})
+else ()
+    message(FATAL_ERROR "Missing library: gtest ")
+endif ()
+file(GLOB_RECURSE SRC_FILES ${CMAKE_SOURCE_DIR}/src/*.cpp)
+file(GLOB_RECURSE TEST_SRC_FILES ${CMAKE_SOURCE_DIR}/unitests/*.cpp)
+
+# subdirs
+SET(SUB_DIRS)
+file(GLOB children ${CMAKE_SOURCE_DIR}/src/*.h)
+FOREACH (child ${children})
+    IF (IS_DIRECTORY ${child})
+        LIST(APPEND SUB_DIRS ${child})
+    ENDIF ()
+ENDFOREACH ()
+LIST(APPEND SUB_DIRS ${CMAKE_SOURCE_DIR}/src)
+include_directories(${CMAKE_SOURCE_DIR}/include)
+include_directories(${SUB_DIRS})
+
+message(STATUS "All Source File" ${SRC_FILES})
+message(STATUS "All Test Source File" ${TEST_SRC_FILES})
+#message(STATUS "All Head File Dir" ${SUB_DIRS})
 add_executable(runUnitTests
-		PythonWrapperTest.cpp
-		)
+        ${TEST_SRC_FILES}
+        ${SRC_FILES}
+        )
 
 target_link_libraries(runUnitTests
-		dl
-		gtest)
+        dl
+        ${ROCKETMQ_LIBRARIES}
+        ${Boost_LIBRARIES}
+        ${PYTHON_LIBRARIES}
+        ${GTEST_LIBRARIES})
 
 if (UNIX AND NOT APPLE)
-	target_link_libraries(runUnitTests rt)
+    target_link_libraries(runUnitTests rt)
 endif ()
 
 set_target_properties(runUnitTests PROPERTIES
-		RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+        RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+add_test(runUnitTests ${CMAKE_BINARY_DIR}/runUnitTests)
diff --git a/unitests/PythonWrapperTest.cpp b/unitests/PythonWrapperTest.cpp
index 5989335..1004597 100644
--- a/unitests/PythonWrapperTest.cpp
+++ b/unitests/PythonWrapperTest.cpp
@@ -15,12 +15,42 @@
  * limitations under the License.
  */
 #include "gtest/gtest.h"
+#include "PythonWrapper.h"
 
 int main(int argc, char **argv) {
     testing::InitGoogleTest(&argc, argv);
     int ret = RUN_ALL_TESTS();
+    return ret;
+}
+TEST(Version, testVersion) {
+    const char *version = PyGetVersion();
+    const char *versionExp = PyGetVersion();
+    ASSERT_STREQ(version,versionExp);
 }
-
 TEST(Message, testCreateMessage) {
-ASSERT_TRUE(1 == 1);
+    ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageTopic) {
+    ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageKey) {
+    ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageTag) {
+    ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageValue) {
+    ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testSetMessageDelayLevel) {
+    ASSERT_TRUE(1 == 1);
+}
+
+TEST(Message, testDestroyMessage) {
+    ASSERT_TRUE(1 == 1);
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services