diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8b9752..174bc62b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ Version 68: +* Split common tests to a new project + API Changes: * Change BodyReader, BodyWriter requirements diff --git a/example/http-server-fast/CMakeLists.txt b/example/http-server-fast/CMakeLists.txt index f0baca67..5668ec1b 100644 --- a/example/http-server-fast/CMakeLists.txt +++ b/example/http-server-fast/CMakeLists.txt @@ -1,11 +1,12 @@ # Part of Beast GroupSources(include/beast beast) - +GroupSources(example/common common) GroupSources(example/http-server-fast "/") add_executable (http-server-fast ${BEAST_INCLUDES} + ${COMMON_INCLUDES} fields_alloc.hpp http_server_fast.cpp ) diff --git a/example/http-server-fast/http_server_fast.cpp b/example/http-server-fast/http_server_fast.cpp index 3a614613..1d461ca9 100644 --- a/example/http-server-fast/http_server_fast.cpp +++ b/example/http-server-fast/http_server_fast.cpp @@ -7,6 +7,8 @@ #include "fields_alloc.hpp" +#include "../common/mime_types.hpp" + #include #include #include @@ -24,37 +26,6 @@ namespace ip = boost::asio::ip; // from using tcp = boost::asio::ip::tcp; // from namespace http = beast::http; // from -// Return a reasonable mime type based on the extension of a file. -// -beast::string_view -mime_type(boost::filesystem::path const& path) -{ - using beast::iequals; - auto const ext = path.extension().string(); - if(iequals(ext, ".txt")) return "text/plain"; - if(iequals(ext, ".htm")) return "text/html"; - if(iequals(ext, ".html")) return "text/html"; - if(iequals(ext, ".php")) return "text/html"; - if(iequals(ext, ".css")) return "text/css"; - if(iequals(ext, ".js")) return "application/javascript"; - if(iequals(ext, ".json")) return "application/json"; - if(iequals(ext, ".xml")) return "application/xml"; - if(iequals(ext, ".swf")) return "application/x-shockwave-flash"; - if(iequals(ext, ".flv")) return "video/x-flv"; - if(iequals(ext, ".png")) return "image/png"; - if(iequals(ext, ".jpe")) return "image/jpeg"; - if(iequals(ext, ".jpeg")) return "image/jpeg"; - if(iequals(ext, ".jpg")) return "image/jpeg"; - if(iequals(ext, ".gif")) return "image/gif"; - if(iequals(ext, ".bmp")) return "image/bmp"; - if(iequals(ext, ".ico")) return "image/vnd.microsoft.icon"; - if(iequals(ext, ".tiff")) return "image/tiff"; - if(iequals(ext, ".tif")) return "image/tiff"; - if(iequals(ext, ".svg")) return "image/svg+xml"; - if(iequals(ext, ".svgz")) return "image/svg+xml"; - return "application/text"; -} - class http_worker { public: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7a655eeb..d939ddbd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,6 +9,7 @@ if ((NOT "${VARIANT}" STREQUAL "coverage") AND (NOT "${VARIANT}" STREQUAL "ubasan")) add_subdirectory (benchmarks) + add_subdirectory (common) add_subdirectory (server) GroupSources(extras/beast extras) diff --git a/test/Jamfile b/test/Jamfile index 12c7b3f1..01d339cc 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -29,6 +29,7 @@ compile zlib.cpp : coverage:no ubasan:no : ; build-project benchmarks ; +build-project common ; build-project core ; build-project http ; build-project server ; diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt new file mode 100644 index 00000000..96b3fa3a --- /dev/null +++ b/test/common/CMakeLists.txt @@ -0,0 +1,28 @@ +# Part of Beast + +GroupSources(example/common common) +GroupSources(extras/beast extras) +GroupSources(include/beast beast) +GroupSources(test/common "/") + +add_executable (common-test + ${BEAST_INCLUDES} + ${COMMON_INCLUDES} + detect_ssl.cpp + file_body.cpp + mime_types.cpp + rfc7231.cpp + ssl_stream.cpp + write_msg.cpp + main.cpp +) + +target_link_libraries(common-test + Beast + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_FILESYSTEM_LIBRARY} + ) + +if (OPENSSL_FOUND) + target_link_libraries (common-test ${OPENSSL_LIBRARIES}) +endif() diff --git a/test/common/Jamfile b/test/common/Jamfile new file mode 100644 index 00000000..ca992351 --- /dev/null +++ b/test/common/Jamfile @@ -0,0 +1,19 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# + +exe common-test : + detect_ssl.cpp + file_body.cpp + mime_types.cpp + rfc7231.cpp + ssl_stream.cpp + write_msg.cpp + main.cpp + : + coverage:no + ubasan:no + ; diff --git a/test/server/detect_ssl.cpp b/test/common/detect_ssl.cpp similarity index 100% rename from test/server/detect_ssl.cpp rename to test/common/detect_ssl.cpp diff --git a/test/server/file_body.cpp b/test/common/file_body.cpp similarity index 100% rename from test/server/file_body.cpp rename to test/common/file_body.cpp diff --git a/test/common/main.cpp b/test/common/main.cpp new file mode 100644 index 00000000..6335cbf2 --- /dev/null +++ b/test/common/main.cpp @@ -0,0 +1,10 @@ +// +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +int main() +{ +} diff --git a/test/server/mime_types.cpp b/test/common/mime_types.cpp similarity index 100% rename from test/server/mime_types.cpp rename to test/common/mime_types.cpp diff --git a/test/server/rfc7231.cpp b/test/common/rfc7231.cpp similarity index 100% rename from test/server/rfc7231.cpp rename to test/common/rfc7231.cpp diff --git a/test/server/ssl_stream.cpp b/test/common/ssl_stream.cpp similarity index 100% rename from test/server/ssl_stream.cpp rename to test/common/ssl_stream.cpp diff --git a/test/server/write_msg.cpp b/test/common/write_msg.cpp similarity index 100% rename from test/server/write_msg.cpp rename to test/common/write_msg.cpp diff --git a/test/server/CMakeLists.txt b/test/server/CMakeLists.txt index a8b98969..fe7cbbde 100644 --- a/test/server/CMakeLists.txt +++ b/test/server/CMakeLists.txt @@ -1,6 +1,7 @@ # Part of Beast GroupSources(example/server-framework framework) +GroupSources(example/common common) GroupSources(extras/beast extras) GroupSources(include/beast beast) @@ -8,6 +9,7 @@ GroupSources(test/server "/") add_executable (server-test ${BEAST_INCLUDES} + ${COMMON_INCLUDES} ${SERVER_INCLUDES} ../../extras/beast/unit_test/main.cpp file_service.cpp @@ -25,13 +27,6 @@ add_executable (server-test ws_sync_port.cpp ws_upgrade_service.cpp wss_ports.cpp - - detect_ssl.cpp - file_body.cpp - mime_types.cpp - rfc7231.cpp - ssl_stream.cpp - write_msg.cpp ) target_link_libraries(server-test diff --git a/test/server/Jamfile b/test/server/Jamfile index ecced9b3..20117160 100644 --- a/test/server/Jamfile +++ b/test/server/Jamfile @@ -18,17 +18,10 @@ unit-test server-test : service_list.cpp ssl_certificate.cpp tests.cpp - write_msg.cpp ws_async_port.cpp ws_sync_port.cpp ws_upgrade_service.cpp - - detect_ssl.cpp - file_body.cpp - mime_types.cpp - rfc7231.cpp - ssl_stream.cpp - write_msg.cpp + wss_ports.cpp : coverage:no ubasan:no