2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #include <beast/unit_test/amount.hpp>
9 #include <beast/unit_test/dstream.hpp>
10 #include <beast/unit_test/global_suites.hpp>
11 #include <beast/unit_test/match.hpp>
12 #include <beast/unit_test/reporter.hpp>
13 #include <beast/unit_test/suite.hpp>
14 #include <boost/program_options.hpp>
20 # ifndef WIN32_LEAN_AND_MEAN // VC_EXTRALEAN
21 # define WIN32_LEAN_AND_MEAN
23 # undef WIN32_LEAN_AND_MEAN
34 prefix(suite_info
const& s
)
43 print(std::ostream
& os
, suite_list
const& c
)
45 std::size_t manual
= 0;
46 for(auto const& s
: c
)
48 os
<< prefix(s
) << s
.full_name() << '\n';
53 amount(c
.size(), "suite") << " total, " <<
54 amount(manual
, "manual suite") <<
59 // Print the list of suites
60 // Used with the --print command line option
63 print(std::ostream
& os
)
65 os
<< "------------------------------------------\n";
66 print(os
, global_suites());
67 os
<< "------------------------------------------" <<
74 // Simple main used to produce stand
75 // alone executables that run unit tests.
76 int main(int ac
, char const* av
[])
79 using namespace beast::unit_test
;
83 int flags
= _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG
);
84 flags
|= _CRTDBG_LEAK_CHECK_DF
;
85 _CrtSetDbgFlag(flags
);
89 namespace po
= boost::program_options
;
90 po::options_description
desc("Options");
92 ("help,h", "Produce a help message")
93 ("print,p", "Print the list of available test suites")
94 ("suites,s", po::value
<string
>(), "suites to run")
97 po::positional_options_description p
;
99 po::store(po::parse_command_line(ac
, av
, desc
), vm
);
102 dstream log
{std::cerr
};
107 log
<< desc
<< std::endl
;
109 else if(vm
.count("print"))
116 if(vm
.count("suites") > 0)
117 suites
= vm
["suites"].as
<string
>();
121 failed
= r
.run_each_if(global_suites(),
124 failed
= r
.run_each(global_suites());