Skip to content

Commit

Permalink
Fix API change in boost::unit_test::unit_test_log_formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasWoodtli committed Dec 17, 2019
1 parent dd424c1 commit e49847b
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions src/drivers/BoostDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ using ::boost::execution_exception;
namespace cucumber {
namespace internal {


namespace {

test_case* testCase = 0;
boost::function<void()> currentTestBody;
test_case* testCase = 0;
boost::function<void()> currentTestBody;

void exec_test_body() {
if (currentTestBody) {
currentTestBody();
}
void exec_test_body() {
if (currentTestBody) {
currentTestBody();
}

}

bool boost_test_init() {
testCase = BOOST_TEST_CASE(&exec_test_body);
Expand All @@ -37,40 +35,45 @@ bool boost_test_init() {
}

// Freed by Boost's unit test framework on exit
static CukeBoostLogInterceptor *logInterceptor = 0;

}
static CukeBoostLogInterceptor* logInterceptor = 0;

} // namespace

class CukeBoostLogInterceptor : public ::boost::unit_test::unit_test_log_formatter {
public:
const InvokeResult getResult() const;
void reset();

// Formatter
void log_start( std::ostream&, counter_t /*test_cases_amount*/) {};
void log_finish( std::ostream&) {};
void log_build_info( std::ostream&) {};
void log_start(std::ostream&, counter_t /*test_cases_amount*/){};
void log_finish(std::ostream&){};

#if BOOST_VERSION >= 107000
void log_build_info(std::ostream&, bool) {}
#else
void log_build_info(std::ostream&){};
#endif

void test_unit_start( std::ostream&, test_unit const& /*tu*/) {};
void test_unit_finish( std::ostream&, test_unit const& /*tu*/, unsigned long /*elapsed*/) {};
void test_unit_skipped( std::ostream&, test_unit const& /*tu*/) {};
void test_unit_start(std::ostream&, test_unit const& /*tu*/){};
void test_unit_finish(std::ostream&, test_unit const& /*tu*/, unsigned long /*elapsed*/){};
void test_unit_skipped(std::ostream&, test_unit const& /*tu*/){};

void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const&) {};
void log_exception_finish( std::ostream& ) {};
void
log_exception_start(std::ostream&, log_checkpoint_data const&, execution_exception const&){};
void log_exception_finish(std::ostream&){};

void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types /*let*/) {};
void log_entry_value( std::ostream&, const_string value);
void log_entry_value( std::ostream&, lazy_ostream const& value);
void log_entry_finish( std::ostream&) {};
void log_entry_start(std::ostream&, log_entry_data const&, log_entry_types /*let*/){};
void log_entry_value(std::ostream&, const_string value);
void log_entry_value(std::ostream&, lazy_ostream const& value);
void log_entry_finish(std::ostream&){};

void entry_context_start( std::ostream&, log_level /*l*/) {}
void entry_context_start(std::ostream&, log_level /*l*/) {}
#if BOOST_VERSION >= 106500
void log_entry_context( std::ostream&, log_level /*l*/, const_string /*value*/) {}
void entry_context_finish( std::ostream&, log_level /*l*/ ) {}
void log_entry_context(std::ostream&, log_level /*l*/, const_string /*value*/) {}
void entry_context_finish(std::ostream&, log_level /*l*/) {}
#else
void log_entry_context( std::ostream&, const_string /*value*/) {}
void entry_context_finish( std::ostream& ) {}
void log_entry_context(std::ostream&, const_string /*value*/) {}
void entry_context_finish(std::ostream&) {}
#endif

private:
Expand Down Expand Up @@ -113,24 +116,24 @@ const InvokeResult BoostStep::invokeStepBody() {
void BoostStep::initBoostTest() {
int argc = 1;
char dummyArg[] = "dummy";
char *argv[] = { dummyArg };
char* argv[] = {dummyArg};
framework::init(&boost_test_init, argc, argv);
#if BOOST_VERSION >= 105900
framework::finalize_setup_phase();
#endif

logInterceptor = new CukeBoostLogInterceptor;
::boost::unit_test::unit_test_log.set_formatter(logInterceptor);
::boost::unit_test::unit_test_log.set_threshold_level(log_all_errors);
}

void BoostStep::runWithMasterSuite() {
currentTestBody = boost::bind(&BoostStep::body, this);

::boost::unit_test::framework::run(testCase, false);

currentTestBody.clear();
}

}
}
} // namespace internal
} // namespace cucumber

0 comments on commit e49847b

Please sign in to comment.