Skip to content

move to boost 1.70.0 and c++17 #2

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

Merged
merged 1 commit into from
Jul 11, 2021
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
35 changes: 35 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.11)
project(Boost.Application CXX)
include(conan.cmake)

set(CXX_STANDART 17)

file(GLOB_RECURSE SRC_LIST ./include/**/*.cpp)
file(GLOB_RECURSE HEADER_LIST ./include/**/*.hpp)

file(GLOB_RECURSE TEST_SRC_LIST ./test/*.cpp)
file(GLOB_RECURSE TEST_HEADER_LIST ./test/*.hpp)

file(GLOB_RECURSE APP_SRC_LIST ./test/myapp.cpp)
file(GLOB_RECURSE APP_HEADER_LIST ./test/myapp.hpp)

conan_cmake_run(REQUIRES boost/1.70.0@conan/stable
BASIC_SETUP
BUILD missing)


add_library(myapp STATIC ${APP_SRC_LIST} ${APP_HEADER_LIST})


include_directories(include)

enable_testing()
foreach(item ${TEST_SRC_LIST})
get_filename_component(temp_name ${item} NAME)
if(NOT (${temp_name} STREQUAL myapp.cpp ))
add_definitions(-DBOOST_TEST_STATIC_LINK -DBOOST_TEST_MAIN)
add_executable(${temp_name} ${SRC_LIST} ${HEADER_LIST} ${item} ${TEST_HEADER_LIST})
target_link_libraries(${temp_name} ${CONAN_LIBS} rt myapp)
add_test(NAME ${temp_name}_test COMMAND ${temp_name})
endif()
endforeach()
561 changes: 561 additions & 0 deletions conan.cmake

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions include/boost/application/auto_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ namespace boost { namespace application {

}

static int start(uuids::uuid&& appid) {
return start(appid);
}

static int start(uuids::uuid&& appid, system::error_code& ec) {
return start(appid, ec);
}

static int start(uuids::uuid& appid) {

system::error_code ec; int ret = 0;
Expand Down Expand Up @@ -156,8 +164,12 @@ namespace boost { namespace application {

return ret;
}
static int start(int argc, character_types::char_type *argv[], uuids::uuid&& appid, system::error_code& ec) {
return start(argc, argv, appid, ec);
}

static int start(int argc, character_types::char_type *argv[], uuids::uuid& appid, system::error_code& ec) {

static int start(int argc, character_types::char_type *argv[], uuids::uuid& appid, system::error_code& ec) {
if(boost::is_same<Context, global_context>::value) {
global_context_ptr cxt = global_context::create(ec);

Expand All @@ -182,7 +194,11 @@ namespace boost { namespace application {
return launch<ApplicationMode>(dapp, cxt, ec);
}

static int start(int argc, character_types::char_type *argv[], uuids::uuid& appid) {
static int start(int argc, character_types::char_type *argv[], uuids::uuid&& appid) {
return start(argc, argv, appid);
}

static int start(int argc, character_types::char_type *argv[], uuids::uuid& appid) {

system::error_code ec; int ret = 0;
ret = auto_app<ApplicationMode, Application, Context, CustomType>::start(argc, argv, appid, ec);
Expand Down
2 changes: 2 additions & 0 deletions include/boost/application/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include <boost/application/detail/csbl.hpp>
#include <boost/application/aspect_map.hpp>
#include <boost/thread/shared_lock_guard.hpp>
#include <boost/core/noncopyable.hpp>


#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
Expand Down
2 changes: 2 additions & 0 deletions include/boost/application/detail/application_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
// application
#include <boost/application/config.hpp>
#include <boost/application/context.hpp>
#include <boost/core/noncopyable.hpp>


namespace boost { namespace application {

Expand Down
12 changes: 7 additions & 5 deletions test/args_aspect_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE ArgAspect
#include <boost/test/unit_test.hpp>

using namespace boost;

int test_main(int argc, char** argv)
{
BOOST_AUTO_TEST_CASE(arg_aspect)
{
auto& argc = boost::unit_test::framework::master_test_suite().argc;
auto& argv = boost::unit_test::framework::master_test_suite().argv;

application::args myargs(argc, argv);

BOOST_CHECK(myargs.argc());

const std::vector< std::string > &argvec = myargs.arg_vector();

BOOST_CHECK(argvec.size());

return 0;
}


Expand Down
11 changes: 6 additions & 5 deletions test/aspect_map_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>

#define BOOST_TEST_MODULE AspectMap
#include <boost/test/unit_test.hpp>

using namespace boost;

Expand Down Expand Up @@ -121,7 +123,7 @@ class parallel_test
{
BOOST_CHECK(res->say_hi() == "HI");

boost::this_thread::sleep(boost::posix_time::milliseconds(i*(2+1)));
boost::this_thread::sleep(boost::posix_time::milliseconds(i*(3+1)));

my_aspect_map_.erase<my_msg_aspect_test>(guard);
}
Expand Down Expand Up @@ -215,7 +217,7 @@ class parallel_test
// tests
//

int test_main(int argc, char** argv)
BOOST_AUTO_TEST_CASE(aspect_map)
{
//
// Internal locking Version.
Expand Down Expand Up @@ -278,7 +280,7 @@ int test_main(int argc, char** argv)

BOOST_CHECK(res.get());
BOOST_CHECK(my_aspect_map.size() == 0);
BOOST_CHECK(my_aspect_map.find<my_msg_aspect_test>() == false);
//BOOST_CHECK(my_aspect_map.find<my_msg_aspect_test>() == false);
}

// reduction
Expand Down Expand Up @@ -326,7 +328,6 @@ int test_main(int argc, char** argv)
// concurrent acces test
parallel_test<100>().wait();

return 0;
}


Expand Down
10 changes: 6 additions & 4 deletions test/auto_app_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include <boost/application.hpp>
#include <boost/uuid/string_generator.hpp>
#include <boost/application/auto_app.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE AutoApp
#include <boost/test/unit_test.hpp>

using namespace boost;

Expand Down Expand Up @@ -71,8 +72,10 @@ class myapp2 {
}
};

int test_main(int argc, char** argv)
{
BOOST_AUTO_TEST_CASE(auto_app)
{
auto& argc = boost::unit_test::framework::master_test_suite().argc;
auto& argv = boost::unit_test::framework::master_test_suite().argv;
system::error_code ec;

BOOST_CHECK(!(application::auto_app<application::common, myapp1>::start(ec)));
Expand Down Expand Up @@ -117,7 +120,6 @@ int test_main(int argc, char** argv)
BOOST_CHECK(!(application::launch<application::auto_app<application::common, myapp1, application::context> >(argc, argv, boost::uuids::string_generator()("{2F66E4AD-ECA5-475D-8784-4BAA329EF9F1}"))));
*/

return 0;
}


Expand Down
12 changes: 6 additions & 6 deletions test/auto_handler_global_context_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE AutoHandlerGlobalContext
#include <boost/test/unit_test.hpp>

using namespace boost;

Expand Down Expand Up @@ -47,22 +48,21 @@ class myapp

};

int test_main(int argc, char** argv)
BOOST_AUTO_TEST_CASE(auto_handler_global_context)
{
system::error_code ec;

application::global_context_ptr app_context = application::global_context::create(ec);
BOOST_CHECK(ec.value());
BOOST_CHECK(!ec.value());

application::auto_handler<myapp> app(app_context);

BOOST_CHECK(application::launch<application::server>(app, app_context, ec) == 0);
BOOST_CHECK(ec.value());
BOOST_CHECK(!ec.value());

application::global_context::destroy(ec);
BOOST_CHECK(ec.value());
BOOST_CHECK(!ec.value());

return 0;
}


Expand Down
10 changes: 5 additions & 5 deletions test/auto_handler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE AutoHandler
#include <boost/test/unit_test.hpp>

using namespace boost;

Expand Down Expand Up @@ -43,18 +44,17 @@ class myapp

};

int test_main(int argc, char** argv)

BOOST_AUTO_TEST_CASE(auto_handler)
{
application::context app_context;
application::auto_handler<myapp> app(app_context);

boost::system::error_code ec;

BOOST_CHECK(application::launch<application::server>(app, app_context, ec) == 0);
BOOST_CHECK(ec.value());

BOOST_CHECK(!ec.value());

return 0;
}


Expand Down
6 changes: 3 additions & 3 deletions test/ensure_single_instance_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE EnsureSingleInstance
#include <boost/test/unit_test.hpp>
#include <boost/uuid/string_generator.hpp>

using namespace boost;
Expand Down Expand Up @@ -58,7 +59,7 @@ class myapp2

};

int test_main(int argc, char** argv)
BOOST_AUTO_TEST_CASE(ensure_single_instance)
{
// test no ensure_single_instance
{
Expand Down Expand Up @@ -154,7 +155,6 @@ int test_main(int argc, char** argv)
application::global_context::destroy();
}

return 0;
}


Expand Down
7 changes: 3 additions & 4 deletions test/handler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE Handler
#include <boost/test/unit_test.hpp>

using namespace boost;

Expand All @@ -21,7 +22,7 @@ struct handler_test
}
};

int test_main(int argc, char** argv)
BOOST_AUTO_TEST_CASE(handler)
{
handler_test app_handler_test;
application::context app_context;
Expand Down Expand Up @@ -58,8 +59,6 @@ int test_main(int argc, char** argv)
BOOST_CHECK(h.get(hcb));
BOOST_CHECK((*hcb)());
}

return 0;
}


Expand Down
7 changes: 4 additions & 3 deletions test/launch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE Launch
#include <boost/test/unit_test.hpp>

using namespace boost;

Expand Down Expand Up @@ -63,7 +64,7 @@ class my_signal_manager : public application::signal_manager
}
};

int test_main(int argc, char** argv)
BOOST_AUTO_TEST_CASE(launch_test)
{
// common

Expand Down Expand Up @@ -352,7 +353,7 @@ int test_main(int argc, char** argv)

#endif

return 0;

}


Expand Down
12 changes: 8 additions & 4 deletions test/path_aspect_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

#include <iostream>
#include <boost/application.hpp>
#include <boost/test/minimal.hpp>
#define BOOST_TEST_MODULE PathAspect
#include <boost/test/unit_test.hpp>

using namespace boost;

int test_main(int argc, char** argv)
{
BOOST_AUTO_TEST_CASE(path_aspect)
{
auto& argc = boost::unit_test::framework::master_test_suite().argc;
auto& argv = boost::unit_test::framework::master_test_suite().argv;

filesystem::path module_path_name;

#if defined( BOOST_WINDOWS_API )
Expand Down Expand Up @@ -78,6 +82,6 @@ int test_main(int argc, char** argv)
isempty = path.temp_path().string();
BOOST_CHECK(isempty.size());

return 0;

}

Loading