summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-09-02 22:38:34 +0200
committerJulian Andres Klode <jak@debian.org>2016-09-02 22:38:34 +0200
commit969d33307ae0cc1b433a0462ef1561580ea6ddbc (patch)
tree0322cf6e3a82a1536c4516e8729993ce68af57af /test/libapt
parentf6c10fb46d1193b8181b5846538e2cf7c15ff216 (diff)
parent54dd6baaf16e92c83f63bdb3633df6e603ac19f3 (diff)
Merge tag '1.3_rc4' into ubuntu/master
apt Debian release 1.3~rc4
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/CMakeLists.txt41
-rw-r--r--test/libapt/commandline_test.cc6
-rw-r--r--test/libapt/strutil_test.cc2
-rw-r--r--test/libapt/tagsection_test.cc2
4 files changed, 29 insertions, 22 deletions
diff --git a/test/libapt/CMakeLists.txt b/test/libapt/CMakeLists.txt
index 7f9990526..f3df14848 100644
--- a/test/libapt/CMakeLists.txt
+++ b/test/libapt/CMakeLists.txt
@@ -1,22 +1,33 @@
-include(ExternalProject)
-
set(GTEST_ROOT "/usr/src/gtest" CACHE FILEPATH "Path to GTest CMake project")
-message(STATUS "Found GTest at ${GTEST_ROOT}")
+find_package(GTest)
+set(GTEST_DEPENDENCIES)
+
+if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT})
+ include(ExternalProject)
+ ExternalProject_Add(gtest PREFIX ./gtest
+ SOURCE_DIR ${GTEST_ROOT}
+ INSTALL_COMMAND true)
-if (EXISTS ${GTEST_ROOT})
+ link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build)
-ExternalProject_Add(gtest PREFIX ./gtest
- SOURCE_DIR ${GTEST_ROOT}
- INSTALL_COMMAND true)
+ set(GTEST_LIBRARIES "-lgtest")
+ set(GTEST_DEPENDENCIES "gtest")
+ set(GTEST_FOUND TRUE)
+ find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h)
-link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build)
-FILE(GLOB files gtest_runner.cc *-helpers.cc *_test.cc)
-add_executable(libapt_test ${files})
-target_link_libraries(libapt_test -lgtest ${CMAKE_THREAD_LIBS_INIT} apt-private apt-inst)
-add_dependencies(libapt_test gtest)
-add_test(NAME AptTests
- COMMAND libapt_test
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ message(STATUS "Found GTest at ${GTEST_ROOT}, headers at ${GTEST_INCLUDE_DIRS}")
+endif()
+if(GTEST_FOUND)
+ file(GLOB files gtest_runner.cc *-helpers.cc *_test.cc)
+ add_executable(libapt_test ${files})
+ target_include_directories(libapt_test PRIVATE ${GTEST_INCLUDE_DIRS})
+ target_link_libraries(libapt_test ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} apt-private apt-inst)
+ if (GTEST_DEPENDENCIES)
+ add_dependencies(libapt_test ${GTEST_DEPENDENCIES})
+ endif()
+ add_test(NAME AptTests
+ COMMAND libapt_test
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc
index 7783c47a4..97725c854 100644
--- a/test/libapt/commandline_test.cc
+++ b/test/libapt/commandline_test.cc
@@ -17,10 +17,6 @@ class CLT: public CommandLine {
}
};
-bool ShowHelp(CommandLine &) {return false;}
-std::vector<aptDispatchWithHelp> GetCommands() {return {};}
-
-
TEST(CommandLineTest,SaveInConfig)
{
#define APT_EXPECT_CMD(x, ...) { const char * const argv[] = { __VA_ARGS__ }; EXPECT_EQ(x, CLT::AsString(argv, sizeof(argv)/sizeof(argv[0]))); }
@@ -166,7 +162,7 @@ TEST(CommandLineTest, BoolParsing)
}
-bool DoVoid(CommandLine &) { return false; }
+static bool DoVoid(CommandLine &) { return false; }
TEST(CommandLineTest,GetCommand)
{
diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc
index 90a5817ad..d7700bd54 100644
--- a/test/libapt/strutil_test.cc
+++ b/test/libapt/strutil_test.cc
@@ -168,7 +168,7 @@ TEST(StrUtilTest,Base64Encode)
EXPECT_EQ("Lg==", Base64Encode("."));
EXPECT_EQ("", Base64Encode(""));
}
-void ReadMessagesTestWithNewLine(char const * const nl, char const * const ab)
+static void ReadMessagesTestWithNewLine(char const * const nl, char const * const ab)
{
SCOPED_TRACE(SubstVar(SubstVar(nl, "\n", "n"), "\r", "r") + " # " + ab);
FileFd fd;
diff --git a/test/libapt/tagsection_test.cc b/test/libapt/tagsection_test.cc
index f250177af..779932595 100644
--- a/test/libapt/tagsection_test.cc
+++ b/test/libapt/tagsection_test.cc
@@ -24,7 +24,7 @@ std::string overrideValue = "1";
std::cerr << "«" << std::endl;;
*/
-void setupTestcaseStart(FileFd &fd, pkgTagSection &section, std::string &content)
+static void setupTestcaseStart(FileFd &fd, pkgTagSection &section, std::string &content)
{
createTemporaryFile("writesection", fd, NULL, NULL);
content = "Package: " + packageValue + "\n"