vongosling closed pull request #11: Add Gtest and quick build boost python shell
URL: https://github.com/apache/rocketmq-client-python/pull/11
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 bc9813a..12c0500 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,13 @@ if (COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
endif ()
+if (POLICY CMP0048)
+ cmake_policy(SET CMP0048 NEW)
+endif ()
+
+if (POLICY CMP0064)
+ cmake_policy(SET CMP0064 NEW)
+endif ()
# First, declare project (important for prerequisite checks).
project(rocketmq-client-python)
@@ -56,7 +63,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif ()
set(CXX_FLAGS
- #-std=c++0x
+ -std=c++11
-g
-Wall
-Wno-deprecated
@@ -151,7 +158,7 @@ option(Boost_USE_STATIC_LIBS "only find boost static libs"
OFF) # find boost lib
if (WIN32)
find_package(Boost REQUIRED COMPONENTS python)
elseif (APPLE)
- find_package(Boost REQUIRED COMPONENTS python27)
+ find_package(Boost REQUIRED COMPONENTS python)
else ()
find_package(Boost REQUIRED COMPONENTS python)
endif (WIN32)
@@ -196,4 +203,14 @@ set(STDC_HEADERS 1)
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)
+ include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
+ add_subdirectory(unitests)
+endif ()
+
add_subdirectory(project)
diff --git a/install_boostpython.sh b/install_boostpython.sh
new file mode 100755
index 0000000..2459df6
--- /dev/null
+++ b/install_boostpython.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+VERSION=1.58.0
+BOOST=boost_1_58_0
+
+if [ ! -d ${HOME}/${BOOST} ]; then
+ if [ -e ${HOME}/${BOOST}.tar.gz ]; then
+ echo "Find Packge ${HOME}/${BOOST}.tar.gz......."
+ else
+ wget -O ${HOME}/${BOOST}.tar.gz
http://sourceforge.net/projects/boost/files/boost/${VERSION}/${BOOST}.tar.gz
+ fi
+ if [ $? -ne 0 ];then
+ exit 1
+ fi
+ tar -xzf ${HOME}/${BOOST}.tar.gz -C ${HOME}
+ if [ $? -ne 0 ];then
+ exit 1
+ fi
+else
+ echo "Find Boost Source:${HOME}/${BOOST}, Build and install....."
+fi
+
+cd ${HOME}/${BOOST}
+
+./bootstrap.sh --prefix=/usr/local --with-libraries=python
+if [ $? -ne 0 ];then
+ exit 1
+fi
+echo "Install boost static library...."
+sudo ./bjam cflags="-fPIC" cxxflags="-fPIC -Wno-unused-local-typedefs
-Wno-strict-aliasing" link=static \
+ --with-python \
+ -a install
+if [ $? -ne 0 ];then
+ exit 1
+fi
+echo "Install boost dynamic library....."
+sudo ./bjam cflags="-fPIC" cxxflags="-fPIC -Wno-unused-local-typedefs
-Wno-strict-aliasing" link=shared \
+ --with-python
+ -a install
diff --git a/third_party/googletest/Readme.md b/third_party/googletest/Readme.md
new file mode 100644
index 0000000..e713348
--- /dev/null
+++ b/third_party/googletest/Readme.md
@@ -0,0 +1,4 @@
+### Google Test
+
+-----------------------
+Download [Here](!https://github.com/abseil/googletest)
diff --git a/unitests/CMakeLists.txt b/unitests/CMakeLists.txt
new file mode 100644
index 0000000..883ec24
--- /dev/null
+++ b/unitests/CMakeLists.txt
@@ -0,0 +1,14 @@
+add_executable(runUnitTests
+ PythonWrapperTest.cpp
+ )
+
+target_link_libraries(runUnitTests
+ dl
+ gtest)
+
+if (UNIX AND NOT APPLE)
+ target_link_libraries(runUnitTests rt)
+endif ()
+
+set_target_properties(runUnitTests PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
diff --git a/unitests/PythonWrapperTest.cpp b/unitests/PythonWrapperTest.cpp
new file mode 100644
index 0000000..5989335
--- /dev/null
+++ b/unitests/PythonWrapperTest.cpp
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "gtest/gtest.h"
+
+int main(int argc, char **argv) {
+ testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+}
+
+TEST(Message, testCreateMessage) {
+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:
[email protected]
With regards,
Apache Git Services