From 704eeb25b2a928f6e7b67e3c92899fcce3ba1bd2 Mon Sep 17 00:00:00 2001 From: FeniksFire Date: Sun, 9 Jul 2017 18:31:21 +0200 Subject: [PATCH] Add googletest as submodule --- .gitmodules | 3 +++ .travis.yml | 9 ++++----- test/CMakeLists.txt | 19 +++++++++++++++---- test/StdInc.h | 4 ++-- test/googletest | 1 + 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 .gitmodules create mode 160000 test/googletest diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..3168f8390 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "test/googletest"] + path = test/googletest + url = https://github.com/google/googletest diff --git a/.travis.yml b/.travis.yml index 3d360465d..068aa0c46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,17 +17,16 @@ matrix: - os: linux compiler: clang env: VCMI_PLATFORM='linux' REAL_CC=clang-3.6 REAL_CXX=clang++-3.6 PACKAGE=clang-3.6 - SUPPORT=libstdc++-4.8-dev VCMI_CMAKE_FLAGS='-DENABLE_TEST=0' + SUPPORT=libstdc++-4.8-dev - os: linux compiler: clang env: VCMI_PLATFORM='linux' REAL_CC=clang-3.4 REAL_CXX=clang++-3.4 PACKAGE=clang-3.4 - SUPPORT=libstdc++-4.8-dev VCMI_CMAKE_FLAGS='-DENABLE_TEST=0' + SUPPORT=libstdc++-4.8-dev - os: linux compiler: gcc env: VCMI_PLATFORM='linux' REAL_CC=gcc-4.8 REAL_CXX=g++-4.8 PACKAGE=g++-4.8 SUPPORT= - VCMI_CMAKE_FLAGS='-DENABLE_TEST=0' - os: linux - env: VCMI_PLATFORM='mxe' MXE_TARGET=i686-w64-mingw32.shared VCMI_CMAKE_FLAGS='-DENABLE_TEST=0' + env: VCMI_PLATFORM='mxe' MXE_TARGET=i686-w64-mingw32.shared sudo: required - os: osx env: VCMI_PLATFORM='mac' @@ -40,7 +39,7 @@ addons: notification_email: coverity@arseniyshestakov.com build_command_prepend: cov-configure --compiler clang-3.6 --comptype clangcc && cov-configure --comptype clangcxx --compiler clang++-3.6 && cmake -G Ninja .. - -DCMAKE_BUILD_TYPE=DEBUG -DENABLE_LAUNCHER=0 -DENABLE_TEST=0 + -DCMAKE_BUILD_TYPE=DEBUG -DENABLE_LAUNCHER=0 build_command: ninja -j 3 branch_pattern: coverity_scan diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e695eab35..8f7f003e4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,10 +1,19 @@ cmake_minimum_required(VERSION 2.8.7) + project(test) + enable_testing() + +set(googleTest_Dir ${CMAKE_CURRENT_SOURCE_DIR}/googletest) +if (EXISTS ${googleTest_Dir}) + SET(GTestSrc ${googleTest_Dir}/googletest) + SET(GMockSrc ${googleTest_Dir}/googlemock) +else () + message( FATAL_ERROR "No googletest src dir found!") +endif () +include_directories(${GTestSrc} ${GTestSrc}/include ${GMockSrc} ${GMockSrc}/include) include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/test) include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) -find_package(GTest REQUIRED) -include_directories(${GTEST_INCLUDE_DIRS}) set(test_SRCS StdInc.cpp @@ -27,8 +36,10 @@ set(test_HEADERS map/MapComparer.h ) -add_executable(vcmitest ${test_SRCS} ${test_HEADERS}) -target_link_libraries(vcmitest vcmi gtest ${RT_LIB} ${DL_LIB}) +add_subdirectory(googletest) + +add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${GTestSrc}/src/gtest-all.cc ${GMockSrc}/src/gmock-all.cc) +target_link_libraries(vcmitest vcmi ${RT_LIB} ${DL_LIB}) add_test(vcmitest vcmitest) vcmi_set_output_dir(vcmitest "") diff --git a/test/StdInc.h b/test/StdInc.h index 0ea466cd6..bd9a35c14 100644 --- a/test/StdInc.h +++ b/test/StdInc.h @@ -8,6 +8,6 @@ * */ #pragma once -#include -#include +#include "gtest/gtest.h" +#include "gmock/gmock.h" #include "Global.h" diff --git a/test/googletest b/test/googletest new file mode 160000 index 000000000..4bab34d20 --- /dev/null +++ b/test/googletest @@ -0,0 +1 @@ +Subproject commit 4bab34d2084259cba67f3bfb51217c10d606e175