From 0e5584920b9fad16bc03f7b6139f2fffd775cf19 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Sun, 8 Apr 2018 17:53:13 +0200 Subject: [PATCH] tests: Use local gtest headers This makes sure the headers and the compiled gtest library are compatible --- .travis.yml | 1 - tests/CMakeLists.txt | 6 +++--- tests/common/test.hpp | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f86f9830..7c32f69b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,7 +65,6 @@ addons: - python-xcbgen - xcb-proto - xutils-dev - - libgtest-dev cache: directories: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6c739cda..691685d3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,7 +28,7 @@ if(result) endif() # Add googletest directly to our build. This defines -# the gtest and gtest_main targets. +# the gtest, gtest_main, gmock and gmock_main targets. add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src ${CMAKE_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL) @@ -51,8 +51,8 @@ function(unit_test file tests) set(name "unit_test.${testname}") add_executable(${name} unit_tests/${file}.cpp ${sources}) - # Link against googletest - target_link_libraries(${name} gtest_main) + # Link against gmock (this automatically links against gtest) + target_link_libraries(${name} gmock_main) add_test(NAME ${name} COMMAND ${name}) diff --git a/tests/common/test.hpp b/tests/common/test.hpp index 5ee1b5e5..f3697bd3 100644 --- a/tests/common/test.hpp +++ b/tests/common/test.hpp @@ -9,7 +9,8 @@ #include #include -#include + +#include "gtest/gtest.h" #define expect(...) \ (void)((__VA_ARGS__) || (expect_fail__(#__VA_ARGS__, __FILE__, __LINE__), 0))