You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2015/11/23 15:17:56 UTC

[3/3] thrift git commit: THRIFT-3442 Run CMake tests on Appveyor Client: Test Patch: Nobuaki Sukegawa

THRIFT-3442 Run CMake tests on Appveyor
Client: Test
Patch: Nobuaki Sukegawa

This closes #713


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/e8c71d8c
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/e8c71d8c
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/e8c71d8c

Branch: refs/heads/master
Commit: e8c71d8cc9d0138cd7f48616ce64b50ae0a1b932
Parents: cacce2f
Author: Nobuaki Sukegawa <ns...@apache.org>
Authored: Mon Nov 23 19:51:37 2015 +0900
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Mon Nov 23 22:45:25 2015 +0900

----------------------------------------------------------------------
 appveyor.yml                    | 60 ++++++++++++++++++++++++++----------
 build/cmake/DefineOptions.cmake |  4 +++
 build/cmake/FindLibevent.cmake  |  6 ++--
 lib/cpp/test/CMakeLists.txt     | 24 ++-------------
 lib/hs/CMakeLists.txt           |  9 +++++-
 test/hs/CMakeLists.txt          | 11 +++++--
 test/hs/TestClient.hs           |  1 -
 test/hs/TestServer.hs           |  4 +--
 8 files changed, 73 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/appveyor.yml
----------------------------------------------------------------------
diff --git a/appveyor.yml b/appveyor.yml
index 0c5bfdf..13afbff 100755
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -18,36 +18,62 @@
 
 # build Apache Thrift on AppVeyor - https://ci.appveyor.com
 
+shallow_clone: true
+clone_depth: 10
+
 version: '{build}'
 os:
-- Windows Server 2012 R2
-- Visual Studio 2014 CTP4
-- Visual Studio 2015 CTP
-- Visual Studio 2015 CTP 6
-- Visual Studio 2015 Preview
+# - Windows Server 2012 R2
+- Visual Studio 2015
 
 environment:
   BOOST_ROOT: c:\Libraries\boost
   BOOST_LIBRARYDIR: c:\Libraries\boost\stage\lib
 
 install:
-- cinst cmake
-- cinst nsis
-- cinst ant
+- '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64'
+  # Zlib
+- appveyor DownloadFile https://github.com/madler/zlib/archive/v1.2.8.tar.gz
+- 7z x v1.2.8.tar.gz -so | 7z x -si -ttar
+- cd zlib-1.2.8
+- cmake -G "Visual Studio 14 2015 Win64" .
+- cmake --build . --config release
+- cd ..
+  # OpenSSL
+- appveyor DownloadFile https://slproweb.com/download/Win64OpenSSL-1_0_2d.exe
+- ps: Start-Process Win64OpenSSL-1_0_2d.exe -ArgumentList "/silent /verysilent /sp- /suppressmsgboxes" -Wait
+  # Libevent
+- appveyor DownloadFile https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
+- 7z x libevent-2.0.22-stable.tar.gz -so | 7z x -si -ttar
+- cd libevent-2.0.22-stable
+- nmake -f Makefile.nmake
+- mkdir lib
+- move *.lib lib\
+- move WIN32-Code\event2\* include\event2\
+- move *.h include\
+- cd ..
 - cinst winflexbison
+- cinst nsis
+# TODO: Enable Java build
+# - cinst ant -ignoreDependencies
+# TODO: Enable Haskell build
+# - cinst HaskellPlatform -version 2014.2.0.0
+
 
 build_script:
-- set PATH=C:\ProgramData\chocolatey\bin;C:\tools\apache-ant-1.9.4\bin;%PATH%
-- mv C:\ProgramData\chocolatey\bin\win_bison.exe C:\ProgramData\chocolatey\bin\bison.exe
-- mv C:\ProgramData\chocolatey\bin\win_flex.exe C:\ProgramData\chocolatey\bin\flex.exe
-- set JAVA_HOME=C:\Program Files\Java\jdk1.7.0
-- set PATH=%JAVA_HOME%\bin;%PATH%
+# - set PATH=C:\ProgramData\chocolatey\bin;C:\tools\apache-ant-1.9.4\bin;%PATH%
+# - set JAVA_HOME=C:\Program Files\Java\jdk1.7.0
+# - set PATH=%JAVA_HOME%\bin;%PATH%
+# - set PATH=%PATH%;C:\Program Files (x86)\Haskell Platform\2014.2.0.0\bin
+# - set PATH=%PATH%;C:\Program Files (x86)\Haskell Platform\2014.2.0.0\lib\extralibs\bin
+- set PATH=C:\Python27-x64;%PATH%
 - mkdir cmake-build
 - cd cmake-build
-- cmake -DBUILD_TESTING=OFF ..
-- cmake --build .
+- cmake -G "Visual Studio 14 2015 Win64" -DWITH_JAVA=OFF -DWITH_SHARED_LIB=OFF -DLIBEVENT_ROOT=%APPVEYOR_BUILD_FOLDER%\libevent-2.0.22-stable -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\release\zlibstatic.lib -DBOOST_ROOT="%BOOST_ROOT% -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR% ..
+# - cmake --build .
 - cmake --build . --config Release
-- cpack
+# TODO: Fix cpack
+# - cpack
+- ctest -C Release -VV -E "(concurrency_test|processor_test|python_test$)"
 
-#TODO enable testing
 #TODO make it perfect ;-r

http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/build/cmake/DefineOptions.cmake
----------------------------------------------------------------------
diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
index 8f7659e..4fb086c 100644
--- a/build/cmake/DefineOptions.cmake
+++ b/build/cmake/DefineOptions.cmake
@@ -49,6 +49,10 @@ CMAKE_DEPENDENT_OPTION(BUILD_CPP "Build C++ library" ON
 # but in future other libraries might reuse them.
 # So they are not dependent on WITH_CPP but setting them without WITH_CPP currently
 # has no effect.
+if(ZLIB_LIBRARY)
+    # FindZLIB.cmake does not normalize path so we need to do it ourselves.
+    file(TO_CMAKE_PATH ${ZLIB_LIBRARY} ZLIB_LIBRARY)
+endif()
 find_package(ZLIB QUIET)
 CMAKE_DEPENDENT_OPTION(WITH_ZLIB "Build with ZLIB support" ON
                        "ZLIB_FOUND" OFF)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/build/cmake/FindLibevent.cmake
----------------------------------------------------------------------
diff --git a/build/cmake/FindLibevent.cmake b/build/cmake/FindLibevent.cmake
index 1eac315..2bcd709 100644
--- a/build/cmake/FindLibevent.cmake
+++ b/build/cmake/FindLibevent.cmake
@@ -6,14 +6,16 @@
 # LIBEVENT_LIBRARIES, LibEvent libraries
 # Libevent_FOUND, If false, do not try to use libevent
 
-set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}")
+set(LIBEVENT_ROOT CACHE PATH "Root directory of libevent installation")
+set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}" ${LIBEVENT_ROOT})
 foreach(prefix ${LibEvent_EXTRA_PREFIXES})
   list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include")
   list(APPEND LibEvent_LIBRARIES_PATHS "${prefix}/lib")
 endforeach()
 
 find_path(LIBEVENT_INCLUDE_DIRS event.h PATHS ${LibEvent_INCLUDE_PATHS})
-find_library(LIBEVENT_LIBRARIES NAMES event PATHS ${LibEvent_LIBRARIES_PATHS})
+# "lib" prefix is needed on Windows
+find_library(LIBEVENT_LIBRARIES NAMES event libevent PATHS ${LibEvent_LIBRARIES_PATHS})
 
 if (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIRS)
   set(Libevent_FOUND TRUE)

http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/lib/cpp/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt
index 491d343..5d017b4 100644
--- a/lib/cpp/test/CMakeLists.txt
+++ b/lib/cpp/test/CMakeLists.txt
@@ -63,7 +63,7 @@ add_executable(Benchmark Benchmark.cpp)
 target_link_libraries(Benchmark testgencpp)
 LINK_AGAINST_THRIFT_LIBRARY(Benchmark thrift)
 add_test(NAME Benchmark COMMAND Benchmark)
-target_link_libraries(Benchmark testgencpp ${ZLIB_LIBRARIES})
+target_link_libraries(Benchmark testgencpp)
 
 set(UnitTest_SOURCES
     UnitTestMain.cpp
@@ -81,8 +81,7 @@ if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS AND NOT MSVC)
 endif()
 
 add_executable(UnitTests ${UnitTest_SOURCES})
-target_link_libraries(UnitTests testgencpp ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES})
+target_link_libraries(UnitTests testgencpp ${Boost_LIBRARIES})
 LINK_AGAINST_THRIFT_LIBRARY(UnitTests thrift)
 add_test(NAME UnitTests COMMAND UnitTests)
 if ( MSVC )
@@ -105,7 +104,6 @@ add_executable(TInterruptTest ${TInterruptTest_SOURCES})
 target_link_libraries(TInterruptTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(TInterruptTest thrift)
 if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -117,7 +115,6 @@ add_executable(TServerIntegrationTest TServerIntegrationTest.cpp)
 target_link_libraries(TServerIntegrationTest
     testgencpp_cob
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(TServerIntegrationTest thrift)
 if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -152,7 +149,6 @@ add_executable(EnumTest EnumTest.cpp)
 target_link_libraries(EnumTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(EnumTest thrift)
 add_test(NAME EnumTest COMMAND EnumTest)
@@ -162,7 +158,6 @@ add_executable(TFileTransportTest TFileTransportTest.cpp)
 target_link_libraries(TFileTransportTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(TFileTransportTest thrift)
 add_test(NAME TFileTransportTest COMMAND TFileTransportTest)
@@ -171,7 +166,6 @@ endif()
 add_executable(TFDTransportTest TFDTransportTest.cpp)
 target_link_libraries(TFDTransportTest
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(TFDTransportTest thrift)
 add_test(NAME TFDTransportTest COMMAND TFDTransportTest)
@@ -179,7 +173,6 @@ add_test(NAME TFDTransportTest COMMAND TFDTransportTest)
 add_executable(TPipedTransportTest TPipedTransportTest.cpp)
 target_link_libraries(TPipedTransportTest
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(TPipedTransportTest thrift)
 add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest)
@@ -194,7 +187,6 @@ add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES})
 target_link_libraries(AllProtocolsTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(AllProtocolsTest thrift)
 add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest)
@@ -205,7 +197,6 @@ add_executable(DebugProtoTest DebugProtoTest.cpp)
 target_link_libraries(DebugProtoTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(DebugProtoTest thrift)
 add_test(NAME DebugProtoTest COMMAND DebugProtoTest)
@@ -215,7 +206,6 @@ add_executable(JSONProtoTest JSONProtoTest.cpp)
 target_link_libraries(JSONProtoTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(JSONProtoTest thrift)
 add_test(NAME JSONProtoTest COMMAND JSONProtoTest)
@@ -224,7 +214,6 @@ add_executable(OptionalRequiredTest OptionalRequiredTest.cpp)
 target_link_libraries(OptionalRequiredTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(OptionalRequiredTest thrift)
 add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest)
@@ -233,7 +222,6 @@ add_executable(RecursiveTest RecursiveTest.cpp)
 target_link_libraries(RecursiveTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(RecursiveTest thrift)
 add_test(NAME RecursiveTest COMMAND RecursiveTest)
@@ -242,7 +230,6 @@ add_executable(SpecializationTest SpecializationTest.cpp)
 target_link_libraries(SpecializationTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(SpecializationTest thrift)
 add_test(NAME SpecializationTest COMMAND SpecializationTest)
@@ -256,7 +243,6 @@ set(concurrency_test_SOURCES
 add_executable(concurrency_test ${concurrency_test_SOURCES})
 LINK_AGAINST_THRIFT_LIBRARY(concurrency_test thrift)
 add_test(NAME concurrency_test COMMAND concurrency_test)
-target_link_libraries(concurrency_test ${ZLIB_LIBRARIES})
 
 set(link_test_SOURCES
     link/LinkTest.cpp
@@ -268,7 +254,7 @@ set(link_test_SOURCES
 add_executable(link_test ${link_test_SOURCES})
 target_link_libraries(link_test testgencpp_cob)
 LINK_AGAINST_THRIFT_LIBRARY(link_test thrift)
-target_link_libraries(link_test testgencpp ${ZLIB_LIBRARIES})
+target_link_libraries(link_test testgencpp)
 add_test(NAME link_test COMMAND link_test)
 
 if(WITH_LIBEVENT)
@@ -284,7 +270,6 @@ add_executable(processor_test ${processor_test_SOURCES})
 target_link_libraries(processor_test
     testgencpp_cob
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(processor_test thrift)
 LINK_AGAINST_THRIFT_LIBRARY(processor_test thriftnb)
@@ -297,7 +282,6 @@ target_link_libraries(TNonblockingServerTest
     testgencpp_cob
     ${LIBEVENT_LIBRARIES}
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thrift)
 LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thriftnb)
@@ -309,7 +293,6 @@ add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
 target_link_libraries(OpenSSLManualInitTest
     ${OPENSSL_LIBRARIES}
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(OpenSSLManualInitTest thrift)
 add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
@@ -318,7 +301,6 @@ add_executable(SecurityTest SecurityTest.cpp)
 target_link_libraries(SecurityTest
     testgencpp
     ${Boost_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 LINK_AGAINST_THRIFT_LIBRARY(SecurityTest thrift)
 if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/lib/hs/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/lib/hs/CMakeLists.txt b/lib/hs/CMakeLists.txt
index f28cb37..37ea288 100644
--- a/lib/hs/CMakeLists.txt
+++ b/lib/hs/CMakeLists.txt
@@ -48,11 +48,18 @@ foreach(SRC ${haskell_sources})
     endif()
 endforeach()
 
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+  set(hs_optimize -O0)
+elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
+  set(hs_optimize -O1)
+endif()
+
 add_custom_command(
     OUTPUT ${haskell_artifacts}
     COMMAND ${CABAL} update
     # Build dependencies first without --builddir, otherwise it fails.
-    COMMAND ${CABAL} install --dependencies-only
+    COMMAND ${CABAL} install --only-dependencies
+    COMMAND ${CABAL} configure ${hs_optimize}
     COMMAND ${CABAL} install --builddir=${CMAKE_CURRENT_BINARY_DIR}/dist
     COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/thrift_cabal.stamp
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}

http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/test/hs/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/test/hs/CMakeLists.txt b/test/hs/CMakeLists.txt
index a65339d..eaca3fa 100644
--- a/test/hs/CMakeLists.txt
+++ b/test/hs/CMakeLists.txt
@@ -61,10 +61,17 @@ set(hs_crosstest_args
     -odir=${CMAKE_CURRENT_BINARY_DIR}
     -hidir=${CMAKE_CURRENT_BINARY_DIR}
 )
+
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+  set(hs_optimize -O0)
+else()
+  set(hs_optimize -O1)
+endif()
+
 add_custom_command(
     OUTPUT ${hs_crosstest_apps}
-    COMMAND ${GHC} ${hs_crosstest_args} ${CMAKE_CURRENT_SOURCE_DIR}/TestServer.hs -o TestServer
-    COMMAND ${GHC} ${hs_crosstest_args} ${CMAKE_CURRENT_SOURCE_DIR}/TestClient.hs -o TestClient
+    COMMAND ${GHC} ${hs_optimize} ${hs_crosstest_args} ${CMAKE_CURRENT_SOURCE_DIR}/TestServer.hs -o TestServer
+    COMMAND ${GHC} ${hs_optimize} ${hs_crosstest_args} ${CMAKE_CURRENT_SOURCE_DIR}/TestClient.hs -o TestClient
     DEPENDS ${hs_test_gen} haskell_library TestServer.hs TestClient.hs
 )
 add_custom_target(haskell_crosstest ALL

http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/test/hs/TestClient.hs
----------------------------------------------------------------------
diff --git a/test/hs/TestClient.hs b/test/hs/TestClient.hs
index 057a560..0ebc0fd 100644
--- a/test/hs/TestClient.hs
+++ b/test/hs/TestClient.hs
@@ -29,7 +29,6 @@ import Network
 import Network.URI
 import System.Environment
 import System.Exit
-import System.Posix.Unistd
 import qualified Data.ByteString.Lazy as LBS
 import qualified Data.HashMap.Strict as Map
 import qualified Data.HashSet as Set

http://git-wip-us.apache.org/repos/asf/thrift/blob/e8c71d8c/test/hs/TestServer.hs
----------------------------------------------------------------------
diff --git a/test/hs/TestServer.hs b/test/hs/TestServer.hs
index 90ec11e..4a88649 100755
--- a/test/hs/TestServer.hs
+++ b/test/hs/TestServer.hs
@@ -31,7 +31,7 @@ import Network
 import System.Environment
 import System.Exit
 import System.IO
-import System.Posix.Unistd
+import Control.Concurrent (threadDelay)
 import qualified System.IO as IO
 import qualified Data.HashMap.Strict as Map
 import qualified Data.HashSet as Set
@@ -241,7 +241,7 @@ instance ThriftTest_Iface TestHandler where
 
   testOneway _ i = do
     System.IO.putStrLn $ "testOneway(" ++ show i ++ "): Sleeping..."
-    sleep (fromIntegral i)
+    threadDelay $ (fromIntegral i) * 1000000
     System.IO.putStrLn $ "testOneway(" ++ show i ++ "): done sleeping!"
 
 main :: IO ()