Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not define BOOST_TEST_DYN_LINK when statically linking #1750

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ add_executable(vw-unit-test.out
target_include_directories(vw-unit-test.out PRIVATE $<TARGET_PROPERTY:vw,INCLUDE_DIRECTORIES>)
target_link_libraries(vw-unit-test.out PRIVATE vw allreduce Boost::unit_test_framework Boost::system)

# Communicate that Boost Unit Test is being statically linked
if(STATIC_LINK_VW)
target_compile_definitions(vw-unit-test.out PRIVATE STATIC_LINK_VW)
endif()

add_test(
NAME vw_unit_test
COMMAND ./vw-unit-test.out
Expand Down
6 changes: 4 additions & 2 deletions test/unit_test/cb_explore_adf_test.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

#ifndef STATIC_LINK_VW
#define BOOST_TEST_DYN_LINK
#endif

#include <boost/test/unit_test.hpp>

#include "vw.h"

BOOST_AUTO_TEST_CASE(cb_explore_adf_should_throw_empty_multi_example) {
auto vw = VW::initialize("--cb_explore_adf", nullptr, false, nullptr, nullptr);
multi_ex example_collection;

multi_ex example_collection;
// An empty example collection is invalid and so should throw.
BOOST_REQUIRE_THROW(vw->learn(example_collection), VW::vw_exception);
}
2 changes: 2 additions & 0 deletions test/unit_test/explore_test.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef STATIC_LINK_VW
#define BOOST_TEST_DYN_LINK
#endif

#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
Expand Down
3 changes: 3 additions & 0 deletions test/unit_test/main.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef STATIC_LINK_VW
#define BOOST_TEST_DYN_LINK
#endif

#define BOOST_TEST_MODULE Main
#include <boost/test/unit_test.hpp>
2 changes: 2 additions & 0 deletions test/unit_test/options_boost_po_test.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef STATIC_LINK_VW
#define BOOST_TEST_DYN_LINK
#endif

#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
Expand Down
2 changes: 2 additions & 0 deletions test/unit_test/options_test.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef STATIC_LINK_VW
#define BOOST_TEST_DYN_LINK
#endif

#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
Expand Down
2 changes: 2 additions & 0 deletions test/unit_test/stable_unique_tests.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef STATIC_LINK_VW
#define BOOST_TEST_DYN_LINK
#endif

#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
Expand Down