Skip to content

Commit

Permalink
Investigate VS2015 test error
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed Sep 1, 2024
1 parent 6b6db13 commit 1deca3e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 45 deletions.
39 changes: 1 addition & 38 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,6 @@ configuration: Release

environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
G: "Ninja"
BOOST_ROOT: C:\Libraries\boost_1_84_0
MSSQL_VER: 2019
POSTGRESQL_ROOT: C:\Program Files\PostgreSQL\15
POSTGRESQL_VER: 15
MYSQL_VER: 80
MYSQL_DIR: C:\Program Files\MySql\MySQL Server 8.0
VCVARS_SCRIPT: "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
G: "Ninja"
BOOST_ROOT: C:\Libraries\boost_1_77_0
MSSQL_VER: 2017
POSTGRESQL_ROOT: C:\Program Files\PostgreSQL\13
POSTGRESQL_VER: 13
MYSQL_VER: 80
MYSQL_DIR: C:\Program Files\MySql\MySQL Server 8.0
VCVARS_SCRIPT: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
G: "Ninja"
BOOST_ROOT: C:\Libraries\boost_1_69_0
MSSQL_VER: 2016
POSTGRESQL_ROOT: C:\Program Files\PostgreSQL\12
POSTGRESQL_VER: 12
MYSQL_VER: 57
MYSQL_DIR: C:\Program Files\MySql\MySQL Server 5.7
VCVARS_SCRIPT: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
G: "Ninja"
BOOST_ROOT: C:\Libraries\boost_1_60_0
Expand All @@ -44,16 +17,6 @@ environment:
MYSQL_VER: 57
MYSQL_DIR: C:\Program Files\MySql\MySQL Server 5.7
VCVARS_SCRIPT: "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
G: "MinGW Makefiles"
MINGW_BIN: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
MSSQL_VER: 2014
BOOST_ROOT: C:\Libraries\boost_1_60_0
POSTGRESQL_ROOT: C:\Program Files\PostgreSQL\9.4
POSTGRESQL_VER: 9.4
MYSQL_VER: 57
MYSQL_DIR: C:\Program Files\MySql\MySQL Server 5.7
VCVARS_SCRIPT: "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC"

install:
# Start these ones here as we can't specify the service name dynamically above.
Expand Down Expand Up @@ -132,7 +95,7 @@ build_script:
- cmake --build . --config %CONFIGURATION% -- %BUILD_TOOL_OPTIONS%

test_script:
- ctest -V --timeout 300 --output-on-failure --build-config %CONFIGURATION% --exclude-regex "%SOCI_ODBC_SKIP_TESTS%"
- ctest -V --timeout 300 --verbose --build-config %CONFIGURATION% --exclude-regex "%SOCI_ODBC_SKIP_TESTS%"

# Uncomment this to wait for RDP connection after the build end.
#on_finish:
Expand Down
12 changes: 10 additions & 2 deletions include/soci/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <ostream>

#include <iostream>

namespace soci
{

Expand Down Expand Up @@ -69,9 +71,15 @@ class SOCI_DECL logger
void start_query(std::string const & query) { m_impl->start_query(query); }

// Methods used for the implementation of session basic logging support.
void set_stream(std::ostream * s) { m_impl->set_stream(s); }
void set_stream(std::ostream * s) {
std::cerr << "Setting stream on logger_impl (" << typeid(*m_impl).name() << ")" << std::endl;
m_impl->set_stream(s);
}
std::ostream * get_stream() const { return m_impl->get_stream(); }
std::string get_last_query() const { return m_impl->get_last_query(); }
std::string get_last_query() const {
std::cerr << "Asking logger_impl (" << typeid(*m_impl).name() << ") for last query" << std::endl;
return m_impl->get_last_query();
}

private:
logger_impl * m_impl;
Expand Down
1 change: 1 addition & 0 deletions src/core/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ logger_impl::~logger_impl()

void logger_impl::set_stream(std::ostream *)
{
std::cerr << "Setting stream on logger_impl base class" << std::endl;
throw_not_supported();
}

Expand Down
12 changes: 7 additions & 5 deletions src/core/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
#include "soci/soci-backend.h"
#include "soci/query_transformation.h"

#include <iostream>

using namespace soci;
using namespace soci::details;

namespace // anonymous
{

void ensureConnected(session_backend * backEnd)
{
if (backEnd == NULL)
Expand Down Expand Up @@ -47,6 +46,7 @@ class standard_logger_impl : public logger_impl

virtual void set_stream(std::ostream * s) override
{
std::cerr << "Setting log stream on standard_logger_impl" << std::endl;
logStream_ = s;
}

Expand All @@ -70,8 +70,6 @@ class standard_logger_impl : public logger_impl
std::string lastQuery_;
};

} // namespace anonymous

session::session()
: once(this), prepare(this),
logger_(new standard_logger_impl),
Expand Down Expand Up @@ -417,10 +415,12 @@ void session::set_log_stream(std::ostream * s)
{
if (isFromPool_)
{
std::cerr << "Setting log stream via pool" << std::endl;
pool_->at(poolPosition_).set_log_stream(s);
}
else
{
std::cerr << "Setting log stream directly" << std::endl;
logger_.set_stream(s);
}
}
Expand Down Expand Up @@ -453,10 +453,12 @@ std::string session::get_last_query() const
{
if (isFromPool_)
{
std::cerr << "Referring query retrieval to pooled session" << std::endl;
return pool_->at(poolPosition_).get_last_query();
}
else
{
std::cerr << "Asking logger (" << typeid(logger_).name() << ") directly" << std::endl;
return logger_.get_last_query();
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/common-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2969,18 +2969,26 @@ TEST_CASE_METHOD(common_tests, "Bulk fetch with single use", "[core][bulk]")
// test for basic logging support
TEST_CASE_METHOD(common_tests, "Basic logging support", "[core][logging]")
{
std::cerr << "Starting basic logging test case" << std::endl;

soci::session sql(backEndFactory_, connectString_);

std::cerr << "About to set log stream" << std::endl;

std::ostringstream log;
sql.set_log_stream(&log);

std::cerr << "Log stream set" << std::endl;

try
{
sql << "drop table soci_test1";
}
catch (...) {}

std::cerr << "Asking logger for last query..." << std::endl;
CHECK(sql.get_last_query() == "drop table soci_test1");
std::cerr << "Done asking" << std::endl;

sql.set_log_stream(NULL);

Expand Down

0 comments on commit 1deca3e

Please sign in to comment.