fix(Data):

adjust make and CMake for SQLParser and DataTest lib
separate samples from tests in CMake
remove unused StatementImpl from Data testsuite
This commit is contained in:
Alex Fabijanic 2023-11-04 23:11:38 +01:00
parent a7a6f869c1
commit 81d7307fa7
47 changed files with 488 additions and 425 deletions

View File

@ -24,7 +24,7 @@
"${POCO_BASE}/MongoDB/include",
"${POCO_BASE}/ApacheConnector/include",
"${POCO_BASE}/Data/src",
"${POCO_BASE}/Data/testsuite/include"
"${POCO_BASE}/Data/testsuite/DataTest/include"
]
},
"configurations": [

View File

@ -21,6 +21,6 @@ target_include_directories(mod_poco
)
target_link_libraries(mod_poco PUBLIC Poco::Util Poco::Net Apache::Apr Apache::Aprutil)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()

View File

@ -204,7 +204,10 @@ if(ENABLE_ACTIVERECORD AND NOT ENABLE_XML)
endif()
option(ENABLE_TESTS
"Set to OFF|ON (default is OFF) to control build of POCO tests & samples" OFF)
"Set to OFF|ON (default is OFF) to control build of POCO tests" OFF)
option(ENABLE_SAMPLES
"Set to OFF|ON (default is OFF) to control build of POCO samples" OFF)
option(POCO_UNBUNDLED
"Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF)
@ -393,7 +396,13 @@ if(OPENSSL_FOUND)
endif()
endif(OPENSSL_FOUND)
option(POCO_DATA_NO_SQL_PARSER "Disable SQL parser" OFF)
if(EXISTS ${PROJECT_SOURCE_DIR}/Data AND ENABLE_DATA)
if(POCO_DATA_NO_SQL_PARSER)
add_definitions(-DPOCO_DATA_NO_SQL_PARSER=1)
endif()
add_subdirectory(Data)
list(APPEND Poco_COMPONENTS "Data")
endif()

View File

@ -38,3 +38,6 @@ elseif(MINGW)
PUBLIC
_DLL)
endif()
POCO_INSTALL(CppUnit)
POCO_GENERATE_PACKAGE(CppUnit)

View File

@ -11,6 +11,6 @@ objects = CppUnitException TestDecorator TestResult TestSuite \
target = CppUnit
target_version = 1
target_libs =
target_libs = PocoFoundation
include $(POCO_BASE)/build/rules/lib

View File

@ -0,0 +1,3 @@
include(CMakeFindDependencyMacro)
find_dependency(PocoFoundation)
include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTargets.cmake")

1
CppUnit/dependencies Normal file
View File

@ -0,0 +1 @@
Foundation

View File

@ -40,7 +40,10 @@ endif()
POCO_INSTALL(Crypto)
POCO_GENERATE_PACKAGE(Crypto)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -1,6 +1,11 @@
# Sources
file(GLOB SRCS_G "src/*.cpp")
POCO_SOURCES_AUTO(SRCS ${SRCS_G})
if (NOT POCO_DATA_NO_SQL_PARSER)
file(GLOB_RECURSE SRCS_PARSER "src/sql-parser/src/*.cpp")
LIST(REMOVE_ITEM SRCS_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/src/sql-parser/src/parser/conflict_test.cpp")
POCO_SOURCES_AUTO(SRCS ${SRCS_PARSER})
endif()
# Headers
file(GLOB_RECURSE HDRS_G "include/*.h")
@ -30,6 +35,7 @@ target_link_libraries(Data PUBLIC Poco::Foundation)
target_include_directories(Data
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
)
@ -37,6 +43,10 @@ target_include_directories(Data
POCO_INSTALL(Data)
POCO_GENERATE_PACKAGE(Data)
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()
if(ENABLE_DATA_SQLITE)
# SQlite3 is built in any case
message(STATUS "SQLite Support Enabled")
@ -66,7 +76,6 @@ else()
message(STATUS "ODBC Support Disabled")
endif()
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
add_subdirectory(testsuite)
endif()

View File

@ -25,4 +25,5 @@ else()
)
set_tests_properties(DataMySQL PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif()
target_link_libraries(DataMySQL-testrunner PUBLIC Poco::DataMySQL CppUnit)
target_link_libraries(DataMySQL-testrunner PUBLIC Poco::DataMySQL Poco::DataTest CppUnit)
target_include_directories(DataMySQL-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/)

View File

@ -25,4 +25,6 @@ else()
)
set_tests_properties(DataODBC PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif()
target_link_libraries(DataODBC-testrunner PUBLIC Poco::DataODBC CppUnit)
target_link_libraries(DataODBC-testrunner PUBLIC Poco::DataTest Poco::DataODBC Poco::Data CppUnit)
target_include_directories(DataODBC-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/)

View File

@ -35,7 +35,6 @@ ifeq ($(POCO_CONFIG),MinGW)
objects += ODBCAccessTest
endif
target_includes = $(POCO_BASE)/Data/testsuite/include
ifndef POCO_DATA_NO_SQL_PARSER
target_includes += $(POCO_BASE)/Data/src
endif
@ -43,5 +42,6 @@ endif
target = testrunner
target_version = 1
target_libs = PocoDataODBC PocoDataTest PocoData PocoFoundation CppUnit
target_includes += $(POCO_BASE)/Data/testsuite/DataTest/include
include $(POCO_BASE)/build/rules/exec

View File

@ -17,4 +17,5 @@ add_test(
COMMAND DataPostgreSQL-testrunner -ignore ${CMAKE_SOURCE_DIR}/cppignore.lnx -all
)
set_tests_properties(DataPostgreSQL PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
target_link_libraries(DataPostgreSQL-testrunner PUBLIC Poco::DataPostgreSQL CppUnit)
target_link_libraries(DataPostgreSQL-testrunner PUBLIC Poco::DataPostgreSQL Poco::DataTest CppUnit)
target_include_directories(DataPostgreSQL-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/)

View File

@ -4,7 +4,8 @@ POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G})
# Headers
file(GLOB_RECURSE HDRS_G "src/*.h")
POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G})
file(GLOB HDRS_E ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/*.h)
POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_E})
POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF
src/WinDriver.cpp
@ -29,4 +30,6 @@ else()
)
set_tests_properties(DataSQLite PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif()
target_link_libraries(DataSQLite-testrunner PUBLIC Poco::DataSQLite CppUnit)
target_link_libraries(DataSQLite-testrunner PUBLIC Poco::DataSQLite Poco::DataTest CppUnit)
target_include_directories(DataSQLite-testrunner PUBLIC ${CMAKE_SOURCE_DIR}/Data/testsuite/DataTest/include/)

View File

@ -544,7 +544,7 @@ private:
/// Returns true if the statement is of the argument type.
Poco::SharedPtr<Parser::SQLParserResult> _pParseResult;
std::string _parseError;
#endif // POCO_DATA_NO_SQL_PARSER
StatementImpl::Ptr _pImpl;
@ -557,7 +557,6 @@ private:
std::vector<Any> _arguments;
RowFormatter::Ptr _pRowFormatter;
mutable std::string _stmtString;
std::string _parseError;
};
//
@ -571,7 +570,12 @@ inline std::size_t Statement::subTotalRowCount(int dataSet) const
inline const std::string& Statement::parseError()
{
#ifdef POCO_DATA_NO_SQL_PARSER
static std::string empty;
return empty;
#else
return _parseError;
#endif
}

View File

@ -48,6 +48,7 @@ Statement::Statement(Session& session):
Statement::Statement(const Statement& stmt):
#ifndef POCO_DATA_NO_SQL_PARSER
_pParseResult(stmt._pParseResult),
_parseError(stmt._parseError),
#endif
_pImpl(stmt._pImpl),
_async(stmt._async),
@ -55,8 +56,7 @@ Statement::Statement(const Statement& stmt):
_pAsyncExec(stmt._pAsyncExec),
_arguments(stmt._arguments),
_pRowFormatter(stmt._pRowFormatter),
_stmtString(stmt._stmtString),
_parseError(stmt._parseError)
_stmtString(stmt._stmtString)
{
}
@ -64,6 +64,7 @@ Statement::Statement(const Statement& stmt):
Statement::Statement(Statement&& stmt) noexcept:
#ifndef POCO_DATA_NO_SQL_PARSER
_pParseResult(std::move(stmt._pParseResult)),
_parseError(std::move(stmt._parseError)),
#endif
_pImpl(std::move(stmt._pImpl)),
_async(std::move(stmt._async)),
@ -71,8 +72,7 @@ Statement::Statement(Statement&& stmt) noexcept:
_pAsyncExec(std::move(stmt._pAsyncExec)),
_arguments(std::move(stmt._arguments)),
_pRowFormatter(std::move(stmt._pRowFormatter)),
_stmtString(std::move(stmt._stmtString)),
_parseError(std::move(stmt._parseError))
_stmtString(std::move(stmt._stmtString))
{
stmt._pImpl = nullptr;
stmt._async = false;
@ -81,7 +81,9 @@ Statement::Statement(Statement&& stmt) noexcept:
stmt._arguments.clear();
stmt._pRowFormatter = nullptr;
_stmtString.clear();
#ifndef POCO_DATA_NO_SQL_PARSER
_parseError.clear();
#endif
}
@ -102,6 +104,8 @@ Statement& Statement::operator = (Statement&& stmt) noexcept
{
#ifndef POCO_DATA_NO_SQL_PARSER
_pParseResult = std::move(stmt._pParseResult);
_parseError = std::move(stmt._parseError);
_parseError.clear();
#endif
_pImpl = std::move(stmt._pImpl);
stmt._pImpl = nullptr;
@ -117,8 +121,6 @@ Statement& Statement::operator = (Statement&& stmt) noexcept
stmt._pRowFormatter = nullptr;
_stmtString = std::move(stmt._stmtString);
_stmtString.clear();
_parseError = std::move(stmt._parseError);
_parseError.clear();
return *this;
}
@ -128,6 +130,7 @@ void Statement::swap(Statement& other) noexcept
using std::swap;
#ifndef POCO_DATA_NO_SQL_PARSER
swap(_pParseResult, other._pParseResult);
swap(_parseError, other._parseError);
#endif
swap(_pImpl, other._pImpl);
swap(_async, other._async);
@ -136,7 +139,6 @@ void Statement::swap(Statement& other) noexcept
_arguments.swap(other._arguments);
swap(_pRowFormatter, other._pRowFormatter);
swap(_stmtString, other._stmtString);
swap(_parseError, other._parseError);
}

View File

@ -1,9 +1,10 @@
# Sources
file(GLOB SRCS_G "src/*.cpp")
LIST(REMOVE_ITEM SRCS_G "${CMAKE_CURRENT_SOURCE_DIR}/src/SQLExecutor.cpp")
POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G})
# Headers
file(GLOB_RECURSE HDRS_G "src/*.h")
file(GLOB HDRS_G "src/*.h")
POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G})
POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF
@ -14,11 +15,6 @@ POCO_SOURCES_AUTO_PLAT(TEST_SRCS WINCE
src/WinCEDriver.cpp
)
#TODO: Why is this file there? It doesn't compile if it is include in the sources
POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF
src/StatementImpl.cpp
)
add_executable(Data-testrunner ${TEST_SRCS})
if(ANDROID)
add_test(
@ -35,3 +31,5 @@ else()
set_tests_properties(Data PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif()
target_link_libraries(Data-testrunner PUBLIC Poco::Data CppUnit)
add_subdirectory(DataTest)

View File

@ -0,0 +1,34 @@
# Sources
file(GLOB SRCS_G ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
POCO_SOURCES_AUTO(DATA_TEST_LIB_SRCS ${SRCS_G})
# Headers
file(GLOB HDRS_G ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
POCO_HEADERS_AUTO(DATA_TEST_LIB_SRCS ${HDRS_G})
# Version Resource
if(MSVC AND BUILD_SHARED_LIBS)
source_group("Resources" FILES ${PROJECT_SOURCE_DIR}/DLLVersion.rc)
list(APPEND DATA_TEST_LIB_SRCS ${PROJECT_SOURCE_DIR}/DLLVersion.rc)
endif()
add_library(DataTest ${DATA_TEST_LIB_SRCS})
add_library(Poco::DataTest ALIAS DataTest)
set_target_properties(DataTest
PROPERTIES
VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION}
OUTPUT_NAME PocoDataTest
DEFINE_SYMBOL DataTest_EXPORTS
)
target_link_libraries(DataTest PUBLIC Poco::Data CppUnit)
target_include_directories(DataTest
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Data/include>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Data/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
POCO_INSTALL(DataTest)
POCO_GENERATE_PACKAGE(DataTest)

View File

@ -0,0 +1,16 @@
#
# Makefile
#
# Makefile for Poco Data testsuite library
#
include $(POCO_BASE)/build/rules/global
objects = SQLExecutor
target = PocoDataTest
target_version = 1
target_libs = PocoData PocoFoundation CppUnit
target_includes = $(POCO_BASE)/Data/src $(POCO_BASE)/Data/testsuite/DataTest/include
include $(POCO_BASE)/build/rules/lib

View File

@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
find_dependency(PocoFoundation)
find_dependency(PocoData)
find_dependency(CppUnit)
include("${CMAKE_CURRENT_LIST_DIR}/PocoDataTestTargets.cmake")

View File

@ -0,0 +1,2 @@
Foundation
Data

View File

@ -0,0 +1,62 @@
//
// DataTest.h
//
// Library: DataTest
// Package: DataTestCore
// Module: DataTest
//
// Basic definitions for the Poco DataTest library.
// This file must be the first file included by every other DataTest
// header file.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.,
// Aleph ONE Software Engineering d.o.o., and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef DataTest_DataTest_INCLUDED
#define DataTest_DataTest_INCLUDED
#include "Poco/Foundation.h"
//
// The following block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the DataTest_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// DataTest_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
//
#if defined(_WIN32) && defined(POCO_DLL)
#if defined(DataTest_EXPORTS)
#define DataTest_API __declspec(dllexport)
#else
#define DataTest_API __declspec(dllimport)
#endif
#endif
#if !defined(DataTest_API)
#if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4)
#define DataTest_API __attribute__ ((visibility ("default")))
#else
#define DataTest_API
#endif
#endif
//
// Automatically link DataTest library.
//
#if defined(_MSC_VER)
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(DataTest_EXPORTS)
#pragma comment(lib, "PocoDataTest" POCO_LIB_SUFFIX)
#endif
#endif
#endif // DataTest_DataTest_INCLUDED

View File

@ -3,18 +3,18 @@
//
// Definition of the SQLExecutor class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.,
// Aleph ONE Software Engineering d.o.o., and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_SQLExecutor_INCLUDED
#define Data_SQLExecutor_INCLUDED
#ifndef DataTest_SQLExecutor_INCLUDED
#define DataTest_SQLExecutor_INCLUDED
#include "Poco/Data/Data.h"
#include "Poco/Data/Test/DataTest.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/BulkExtraction.h"
#include "Poco/Data/BulkBinding.h"
@ -24,6 +24,11 @@
#include <iostream>
namespace Poco {
namespace Data {
namespace Test {
#define poco_data_using_keywords using Poco::Data::Keywords::now; \
using Poco::Data::Keywords::into; \
using Poco::Data::Keywords::use; \
@ -33,12 +38,7 @@
using Poco::Data::CLOB;
namespace Poco {
namespace Data {
namespace Test {
class SQLExecutor: public CppUnit::TestCase
class DataTest_API SQLExecutor: public CppUnit::TestCase
{
public:
enum DataBinding
@ -238,4 +238,4 @@ private:
} } } // Poco::Data::Test
#endif // Data_SQLExecutor_INCLUDED
#endif // DataTest_SQLExecutor_INCLUDED

View File

@ -8,4 +8,4 @@
clean distclean all: projects
projects:
$(MAKE) -f Makefile-testrunner $(MAKECMDGOALS)
$(MAKE) -f Makefile-library $(MAKECMDGOALS)
$(MAKE) -C DataTest $(MAKECMDGOALS)

View File

@ -1,21 +0,0 @@
#
# Makefile
#
# Makefile for Poco Data testsuite library
#
include $(POCO_BASE)/build/rules/global
objects = SQLExecutor
target_includes = $(POCO_BASE)/Data/testsuite/include
ifndef POCO_DATA_NO_SQL_PARSER
objects += SQLParserTest
target_includes += $(POCO_BASE)/Data/src
endif
target = PocoDataTest
target_version = 1
target_libs = PocoData PocoFoundation CppUnit
include $(POCO_BASE)/build/rules/lib

View File

@ -1504,6 +1504,8 @@ void DataTest::testSQLParse()
assertTrue (!stmt.isDelete().isSpecified());
assertTrue (!stmt.hasDelete().isSpecified());
#else
std::cout << "[NOT ENABLED]";
#endif // POCO_DATA_NO_SQL_PARSER
}

View File

@ -1,82 +0,0 @@
//
// StatementImpl.cpp
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "StatementImpl.h"
namespace Poco {
namespace Data {
namespace Test {
StatementImpl::StatementImpl()
{
}
StatementImpl::~StatementImpl()
{
}
void StatementImpl::compileImpl()
{
// prepare binding
_ptrBinder = new Binder;
_ptrExtractor = new Extractor;
_ptrPrepare = new Preparation();
}
bool StatementImpl::canBind() const
{
return false;
}
void StatementImpl::bindImpl()
{
// bind
typedef Poco::Data::AbstractBindingVec Bindings;
Bindings& binds = bindings();
if (binds.empty())
return;
Bindings::iterator it = binds.begin();
Bindings::iterator itEnd = binds.end();
std::size_t pos = 0;
for (; it != itEnd && (*it)->canBind(); ++it)
{
(*it)->bind(pos);
pos += (*it)->numOfColumnsHandled();
}
}
bool StatementImpl::hasNext()
{
return false;
}
void StatementImpl::next()
{
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
std::size_t pos = 0;
for (; it != itEnd; ++it)
{
(*it)->extract(pos);
pos += (*it)->numOfColumnsHandled();
}
}
} } } // namespace Poco::Data::Test

View File

@ -1,91 +0,0 @@
//
// StatementImpl.h
//
// Definition of the StatementImpl class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_Test_StatementImpl_INCLUDED
#define Data_Test_StatementImpl_INCLUDED
#include "Poco/Data/StatementImpl.h"
#include "Poco/SharedPtr.h"
#include "Binder.h"
#include "Extractor.h"
#include "Preparator.h"
struct sqlite3;
struct sqlite3_stmt;
namespace Poco {
namespace Data {
namespace Test {
class StatementImpl: public Poco::Data::StatementImpl
/// A no-op implementation of StatementImpl for testing.
{
public:
StatementImpl();
/// Creates the StatementImpl.
~StatementImpl();
/// Destroys the StatementImpl.
protected:
bool hasNext();
/// Returns true if a call to next() will return data.
void next();
/// Retrieves the next row from the resultset.
/// Will throw, if the resultset is empty.
bool canBind() const;
/// Returns true if a valid statement is set and we can bind.
void compileImpl();
/// Compiles the statement, doesn't bind yet
void bindImpl();
/// Binds parameters
AbstractExtractor& extractor();
/// Returns the concrete extractor used by the statement.
AbstractBinder& binder();
/// Returns the concrete binder used by the statement.
private:
Poco::SharedPtr<Binder> _ptrBinder;
Poco::SharedPtr<Extractor> _ptrExtractor;
Poco::SharedPtr<Preparation> _ptrPrepare;
};
//
// inlines
//
inline AbstractExtractor& StatementImpl::extractor()
{
return *_ptrExtractor;
}
inline AbstractBinder& StatementImpl::binder()
{
return *_ptrBinder;
}
} } } // namespace Poco::Data::Test
#endif // Data_Test_StatementImpl_INCLUDED

View File

@ -0,0 +1,33 @@
# Sources
file(GLOB SRCS_G "src/*.cpp")
LIST(REMOVE_ITEM SRCS_G "${CMAKE_CURRENT_SOURCE_DIR}/src/SQLExecutor.cpp")
POCO_SOURCES_AUTO(TEST_SRCS ${SRCS_G})
# Headers
file(GLOB HDRS_G "src/*.h")
POCO_HEADERS_AUTO(TEST_SRCS ${HDRS_G})
POCO_SOURCES_AUTO_PLAT(TEST_SRCS WIN
src/WinDriver.cpp
)
POCO_SOURCES_AUTO_PLAT(TEST_SRCS WINCE
src/WinCEDriver.cpp
)
add_executable(Data-testrunner ${TEST_SRCS})
if(ANDROID)
add_test(
NAME Data
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} -DLIBRARY_DIR=${CMAKE_BINARY_DIR}/lib -DUNITTEST=${CMAKE_BINARY_DIR}/bin/Data-testrunner -DTEST_PARAMETER=-all -P ${CMAKE_SOURCE_DIR}/cmake/ExecuteOnAndroid.cmake
)
else()
add_test(
NAME Data
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND Data-testrunner -ignore ${CMAKE_SOURCE_DIR}/cppignore.lnx -all
)
set_tests_properties(Data PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR})
endif()
target_link_libraries(Data-testrunner PUBLIC Poco::Data CppUnit)

View File

@ -32,7 +32,10 @@ target_include_directories(Encodings
POCO_INSTALL(Encodings)
POCO_GENERATE_PACKAGE(Encodings)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -234,10 +234,13 @@ endif()
POCO_INSTALL(Foundation)
POCO_GENERATE_PACKAGE(Foundation)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
if(NOT BUILD_SHARED_LIBS)
set_property(TARGET Foundation PROPERTY POSITION_INDEPENDENT_CODE ON) # This is needed to build TestLibrary.so as shared.
endif()
add_subdirectory(samples)
add_subdirectory(testsuite)
endif()

View File

@ -41,7 +41,10 @@ endif()
POCO_INSTALL(JSON)
POCO_GENERATE_PACKAGE(JSON)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -32,8 +32,11 @@ target_include_directories(MongoDB
POCO_INSTALL(MongoDB)
POCO_GENERATE_PACKAGE(MongoDB)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -46,8 +46,11 @@ target_include_directories(Net
POCO_INSTALL(Net)
POCO_GENERATE_PACKAGE(Net)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -36,8 +36,11 @@ endif()
POCO_INSTALL(NetSSL)
POCO_GENERATE_PACKAGE(NetSSL)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -32,9 +32,12 @@ target_include_directories(NetSSLWin
POCO_INSTALL(NetSSLWin)
POCO_GENERATE_PACKAGE(NetSSLWin)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
#TODO: Looks like the samples use crypto somehow?
#add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
#add_subdirectory(testsuite)
endif()

View File

@ -146,8 +146,11 @@ target_include_directories(PDF
POCO_INSTALL(PDF)
POCO_GENERATE_PACKAGE(PDF)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -32,8 +32,11 @@ target_include_directories(Prometheus
POCO_INSTALL(Prometheus)
POCO_GENERATE_PACKAGE(Prometheus)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -34,6 +34,5 @@ POCO_GENERATE_PACKAGE(Redis)
if(ENABLE_TESTS)
add_subdirectory(testsuite)
# add_subdirectory(samples)
endif()

View File

@ -75,7 +75,5 @@ POCO_GENERATE_PACKAGE(SevenZip)
if(ENABLE_TESTS)
add_subdirectory(samples)
# TODO: Add tests
#add_subdirectory(testsuite)
endif()

View File

@ -49,7 +49,10 @@ target_include_directories(Util
POCO_INSTALL(Util)
POCO_GENERATE_PACKAGE(Util)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -65,8 +65,11 @@ endif()
POCO_INSTALL(XML)
POCO_GENERATE_PACKAGE(XML)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -32,8 +32,11 @@ target_include_directories(Zip
POCO_INSTALL(Zip)
POCO_GENERATE_PACKAGE(Zip)
if(ENABLE_TESTS)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
if(ENABLE_TESTS)
add_subdirectory(testsuite)
endif()

View File

@ -222,10 +222,17 @@ else()
NAMESPACE "${PROJECT_NAME}::"
)
endif()
if("${target_name}" STREQUAL "CppUnit")
configure_file("cmake/${target_name}Config.cmake"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake"
@ONLY
)
else()
configure_file("cmake/Poco${target_name}Config.cmake"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake"
@ONLY
)
endif()
# Set config script install location in a location that find_package() will
# look for, which is different on MS Windows than for UNIX

View File

@ -389,6 +389,7 @@ Here an overview of POCO build options:
* ENABLE_PAGECOMPILER_FILE2PAGE Set to OFF|ON (default is ON) to build File2Page
* ENABLE_POCODOC Set to OFF|ON (default is OFF) to build Poco Documentation Generator
* ENABLE_TESTS Set to OFF|ON (default is OFF) to build Unit tests
* ENABLE_SAMPLES Set to OFF|ON (default is OFF) to build samples
* ENABLE_LONG_RUNNING_TESTS Set to OFF|ON (default is ON) to use long running test
* POCO_UNBUNDLED Set to OFF|ON (default is OFF) to control linking dependencies as external

View File

@ -1,20 +1,32 @@
#!/bin/bash
#
# Script to rebuild a library and dependencies
# Script to rebuild libraries and dependencies
# (with or without a sanitizer) and run the tests.
# Currently works only for top-level libs
# dependent on Foundation only.
#
# The use case of the script is mainly for development purposes -
# to clean and rebuild a single library, with all of its dependencies,
# and run the tests.
#
# Usage: ./runLibTests.sh library [address | undefined | thread ]
#
# Example: ./runLibTests.sh Data/SQLite address
# (distcleans, rebuilds and runs tests for Data/SQLite with address sanitizer)
#
library=$1
if [ -z "${library}" ]; then
# g++ does not like empty quoted arguments, but
# the shellcheck wants them quoted to remain quiet
# shellcheck disable=SC2086
path=$1
if [ -z "${path}" ]; then
echo "Library not specified"
echo "Usage: $0 library [address | undefined | thread ]"
echo "Usage: $0 path [address | undefined | thread ]"
exit 1
fi
libraries=
IFS='/' read -r -a libraries <<< "$path"
self="${BASH_SOURCE[0]}"
if [ -d "$self" ] ; then
@ -27,30 +39,41 @@ fi
. "$basedir"/poco_env.bash
flag=$2
make distclean -C CppUnit
make distclean -C Foundation
if [[ "$library" != "Foundation" ]]; then
make distclean -C "$library"
fi
make distclean -C "$library"/testsuite
flags=
if [ -n "${flag}" ]; then
make -s -j4 -C "$POCO_BASE"/CppUnit SANITIZEFLAGS+=-fsanitize="$flag"
make -s -j4 -C "$POCO_BASE"/Foundation SANITIZEFLAGS+=-fsanitize="$flag"
if [[ "$library" != "Foundation" ]]; then
make -s -j4 -C "$POCO_BASE"/"$library" SANITIZEFLAGS+=-fsanitize="$flag"
fi
make -s -j4 -C "$POCO_BASE"/"$library"/testsuite SANITIZEFLAGS+=-fsanitize="$flag"
else
make -s -j4 -C "$POCO_BASE"/CppUnit
make -s -j4 -C "$POCO_BASE"/Foundation
if [[ "$library" != "Foundation" ]]; then
make -s -j4 -C "$POCO_BASE"/"$library"
fi
make -s -j4 -C "$POCO_BASE"/"$library"/testsuite
flags=SANITIZEFLAGS+=-fsanitize="$flag"
fi
cd "$basedir"/"$library"/testsuite/bin/"$OSNAME"/"$OSARCH"/ || exit
path="$basedir"/"${libraries[0]}"
make distclean -C "$basedir"/Foundation
make distclean -C "$basedir"/CppUnit
make -s -j4 -C "$basedir"/Foundation $flags
make -s -j4 -C "$basedir"/CppUnit $flags
# Foundation requested, build/run tests and exit
if [[ "$path" == "$basedir"/"Foundation" ]]; then
cd "$path/testsuite/" || exit
make -s -j4 -C ./ $flags
cd "bin/$OSNAME/$OSARCH/" || exit
./testrunner -all
./testrunnerd -all
echo "$path $flags done."
exit 0
fi
for library in "${libraries[@]}"
do
cd "$library" || exit
make distclean
make -s -j4 -C ./ $flags
cd testsuite || exit
make distclean
make -s -j4 -C ./ $flags
cd bin/"$OSNAME"/"$OSARCH"/ || exit
./testrunner -all
./testrunnerd -all
echo "$1 $flags done."
cd ../../../../ || exit
done