mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Refactor beast core, http, tests, and examples:
* Fix warnings * Port cmake scripts to linux * Add command line options for running test suites * Add examples to CMakeLists * Return std::uint64_t from writer::content_length * basic_parser::write takes asio::const_buffer instead of pointer and size * Turn message test back on now that it passes * Rename to http::headers, use std::allocator, remove http_headers * http::message::method is now a string * Refactor to_string for ConstBufferSequence * Remove chunk_encode from the public interface * Initialize members for default constructed iterators * Disallow default construction for dependent buffer sequences Refactor http::message serialization: * Serialization no longer creates a copy of the headers and modifies them * New function prepare(), sets Connection, Transfer-Encoding, Content-Length based on the body attributes and caller options. Callers can use prepare() to have the fields set automatically, or they can set the fields manually. * Use write for operator<< * Tests for serialization
This commit is contained in:
@@ -17,26 +17,77 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <beast/detail/unit_test/amount.hpp>
|
||||
#include <beast/detail/unit_test/global_suites.hpp>
|
||||
#include <beast/detail/unit_test/match.hpp>
|
||||
#include <beast/detail/unit_test/reporter.hpp>
|
||||
#include <beast/detail/unit_test/suite.hpp>
|
||||
#include <beast/detail/stream/debug_ostream.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# ifndef WIN32_LEAN_AND_MEAN // VC_EXTRALEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# else
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
namespace unit_test {
|
||||
|
||||
std::string
|
||||
prefix(suite_info const& s)
|
||||
{
|
||||
if (s.manual())
|
||||
return "|M| ";
|
||||
return " ";
|
||||
}
|
||||
|
||||
template<class Log>
|
||||
void
|
||||
print(Log& log, suite_list const& c)
|
||||
{
|
||||
std::size_t manual = 0;
|
||||
for(auto const& s : c)
|
||||
{
|
||||
log <<
|
||||
prefix (s) <<
|
||||
s.full_name();
|
||||
if(s.manual())
|
||||
++manual;
|
||||
}
|
||||
log <<
|
||||
amount(c.size(), "suite") << " total, " <<
|
||||
amount(manual, "manual suite")
|
||||
;
|
||||
}
|
||||
|
||||
template<class Log>
|
||||
void
|
||||
print(Log& log)
|
||||
{
|
||||
log << "------------------------------------------";
|
||||
print(log, global_suites());
|
||||
log << "------------------------------------------";
|
||||
}
|
||||
|
||||
} // unit_test
|
||||
} // detail
|
||||
} // beast
|
||||
|
||||
// Simple main used to produce stand
|
||||
// alone executables that run unit tests.
|
||||
int main()
|
||||
int main(int ac, char const* av[])
|
||||
{
|
||||
using namespace std;
|
||||
using namespace beast::detail::unit_test;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -47,10 +98,41 @@ int main()
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace po = boost::program_options;
|
||||
po::options_description desc("Options");
|
||||
desc.add_options()
|
||||
("help,h", "Produce a help message")
|
||||
("print,r", "Print the list of available test suites")
|
||||
("suites,s", po::value<string>(), "suites to run")
|
||||
;
|
||||
|
||||
po::positional_options_description p;
|
||||
po::variables_map vm;
|
||||
po::store(po::parse_command_line(ac, av, desc), vm);
|
||||
po::notify(vm);
|
||||
|
||||
beast::detail::debug_ostream log;
|
||||
|
||||
if(vm.count("help"))
|
||||
{
|
||||
beast::detail::debug_ostream s;
|
||||
reporter r (s);
|
||||
bool failed (r.run_each (global_suites()));
|
||||
log << desc;
|
||||
}
|
||||
else if(vm.count("print"))
|
||||
{
|
||||
print(log);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string suites;
|
||||
if(vm.count("suites") > 0)
|
||||
suites = vm["suites"].as<string>();
|
||||
reporter r(log);
|
||||
bool failed;
|
||||
if(! suites.empty())
|
||||
failed = r.run_each_if(global_suites(),
|
||||
match_auto(suites));
|
||||
else
|
||||
failed = r.run_each(global_suites());
|
||||
if (failed)
|
||||
return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user