File indexing completed on 2025-01-30 10:01:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER
0019 #define BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER
0020
0021
0022 #include <boost/test/unit_test_parameters.hpp>
0023
0024 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
0025 #include <boost/test/utils/basic_cstring/compare.hpp>
0026 #include <boost/test/utils/basic_cstring/io.hpp>
0027 #include <boost/test/utils/iterator/token_iterator.hpp>
0028
0029 #include <boost/test/debug.hpp>
0030 #include <boost/test/framework.hpp>
0031
0032 #include <boost/test/detail/log_level.hpp>
0033 #include <boost/test/detail/throw_exception.hpp>
0034
0035
0036 #include <boost/test/utils/runtime/parameter.hpp>
0037 #include <boost/test/utils/runtime/argument.hpp>
0038 #include <boost/test/utils/runtime/finalize.hpp>
0039 #include <boost/test/utils/runtime/cla/parser.hpp>
0040 #include <boost/test/utils/runtime/env/fetch.hpp>
0041
0042
0043 #include <boost/config.hpp>
0044 #include <boost/test/detail/suppress_warnings.hpp>
0045 #include <boost/test/detail/enable_warnings.hpp>
0046 #include <boost/cstdlib.hpp>
0047
0048
0049 #include <cstdlib>
0050 #include <iostream>
0051 #include <fstream>
0052
0053 #include <boost/test/detail/suppress_warnings.hpp>
0054
0055
0056
0057 # ifdef BOOST_NO_STDC_NAMESPACE
0058 namespace std { using ::getenv; using ::strncmp; using ::strcmp; }
0059 # endif
0060
0061 namespace boost {
0062 namespace unit_test {
0063
0064 namespace rt = boost::runtime;
0065
0066
0067
0068
0069
0070 namespace runtime_config {
0071
0072
0073 std::string btrt_auto_start_dbg = "auto_start_dbg";
0074 std::string btrt_break_exec_path = "break_exec_path";
0075 std::string btrt_build_info = "build_info";
0076 std::string btrt_catch_sys_errors = "catch_system_errors";
0077 std::string btrt_color_output = "color_output";
0078 std::string btrt_detect_fp_except = "detect_fp_exceptions";
0079 std::string btrt_detect_mem_leaks = "detect_memory_leaks";
0080 std::string btrt_list_content = "list_content";
0081 std::string btrt_list_labels = "list_labels";
0082 std::string btrt_log_format = "log_format";
0083 std::string btrt_log_level = "log_level";
0084 std::string btrt_log_sink = "log_sink";
0085 std::string btrt_combined_logger = "logger";
0086 std::string btrt_output_format = "output_format";
0087 std::string btrt_random_seed = "random";
0088 std::string btrt_report_format = "report_format";
0089 std::string btrt_report_level = "report_level";
0090 std::string btrt_report_mem_leaks = "report_memory_leaks_to";
0091 std::string btrt_report_sink = "report_sink";
0092 std::string btrt_result_code = "result_code";
0093 std::string btrt_run_filters = "run_test";
0094 std::string btrt_save_test_pattern = "save_pattern";
0095 std::string btrt_show_progress = "show_progress";
0096 std::string btrt_use_alt_stack = "use_alt_stack";
0097 std::string btrt_wait_for_debugger = "wait_for_debugger";
0098
0099 std::string btrt_help = "help";
0100 std::string btrt_usage = "usage";
0101 std::string btrt_version = "version";
0102
0103
0104
0105 namespace {
0106
0107 void
0108 register_parameters( rt::parameters_store& store )
0109 {
0110 rt::option auto_start_dbg( btrt_auto_start_dbg, (
0111 rt::description = "Automatically attaches debugger in case of system level failure (signal).",
0112 rt::env_var = "BOOST_TEST_AUTO_START_DBG",
0113
0114 rt::help = "Specifies whether Boost.Test should attempt "
0115 "to attach a debugger when fatal system error occurs. At the moment this feature "
0116 "is only available on a few selected platforms: Win32 and *nix. There is a "
0117 "default debugger configured for these platforms. You can manually configure "
0118 "different debugger. For more details on how to configure the debugger see the "
0119 "Boost.Test debug API, specifically the function boost::debug::set_debugger."
0120 ));
0121
0122 auto_start_dbg.add_cla_id( "--", btrt_auto_start_dbg, "=" );
0123 auto_start_dbg.add_cla_id( "-", "d", " " );
0124 store.add( auto_start_dbg );
0125
0126
0127
0128 rt::parameter<std::string> break_exec_path( btrt_break_exec_path, (
0129 rt::description = "For the exception safety testing allows to break at specific execution path.",
0130 rt::env_var = "BOOST_TEST_BREAK_EXEC_PATH"
0131 #ifndef BOOST_NO_CXX11_LAMBDAS
0132 ,
0133 rt::callback = [](rt::cstring) {
0134 BOOST_TEST_SETUP_ASSERT( false, "parameter break_exec_path is disabled in this release" );
0135 }
0136 #endif
0137 ));
0138
0139 break_exec_path.add_cla_id( "--", btrt_break_exec_path, "=" );
0140 store.add( break_exec_path );
0141
0142
0143
0144 rt::option build_info( btrt_build_info, (
0145 rt::description = "Displays library build information.",
0146 rt::env_var = "BOOST_TEST_BUILD_INFO",
0147 rt::help = "Displays library build information, including: platform, "
0148 "compiler, STL version and Boost version."
0149 ));
0150
0151 build_info.add_cla_id( "--", btrt_build_info, "=" );
0152 build_info.add_cla_id( "-", "i", " " );
0153 store.add( build_info );
0154
0155
0156
0157 rt::option catch_sys_errors( btrt_catch_sys_errors, (
0158 rt::description = "Allows to switch between catching and ignoring system errors (signals).",
0159 rt::env_var = "BOOST_TEST_CATCH_SYSTEM_ERRORS",
0160 rt::default_value =
0161 #ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
0162 false,
0163 #else
0164 true,
0165 #endif
0166 rt::help = "If option " + btrt_catch_sys_errors + " has value 'no' the frameworks does not attempt to catch "
0167 "asynchronous system failure events (signals on *NIX platforms or structured exceptions on Windows). "
0168 " Default value is "
0169 #ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
0170 "no."
0171 #else
0172 "true."
0173 #endif
0174 ));
0175
0176 catch_sys_errors.add_cla_id( "--", btrt_catch_sys_errors, "=", true );
0177 catch_sys_errors.add_cla_id( "-", "s", " " );
0178 store.add( catch_sys_errors );
0179
0180
0181
0182 rt::option color_output( btrt_color_output, (
0183 rt::description = "Enables color output of the framework log and report messages.",
0184 rt::env_var = "BOOST_TEST_COLOR_OUTPUT",
0185 rt::default_value = true,
0186 rt::help = "Produces color output for logs, reports and help. "
0187 "Defaults to true. "
0188 ));
0189
0190 color_output.add_cla_id( "--", btrt_color_output, "=", true );
0191 color_output.add_cla_id( "-", "x", " " );
0192 store.add( color_output );
0193
0194
0195
0196 rt::option detect_fp_except( btrt_detect_fp_except, (
0197 rt::description = "Enables/disables floating point exceptions traps.",
0198 rt::env_var = "BOOST_TEST_DETECT_FP_EXCEPTIONS",
0199 rt::help = "Enables/disables hardware traps for the floating "
0200 "point exceptions (if supported on your platfrom)."
0201 ));
0202
0203 detect_fp_except.add_cla_id( "--", btrt_detect_fp_except, "=", true );
0204 store.add( detect_fp_except );
0205
0206
0207
0208 rt::parameter<unsigned long> detect_mem_leaks( btrt_detect_mem_leaks, (
0209 rt::description = "Turns on/off memory leaks detection (optionally breaking on specified alloc order number).",
0210 rt::env_var = "BOOST_TEST_DETECT_MEMORY_LEAK",
0211 rt::default_value = 1L,
0212 rt::optional_value = 1L,
0213 rt::value_hint = "<alloc order number>",
0214 rt::help = "Enables/disables memory leaks detection. "
0215 "This parameter has optional long integer value. The default value is 1, which "
0216 "enables the memory leak detection. The value 0 disables memory leak detection. "
0217 "Any value N greater than 1 is treated as leak allocation number and tells the "
0218 "framework to setup runtime breakpoint at Nth heap allocation. If value is "
0219 "omitted the default value is assumed."
0220 ));
0221
0222 detect_mem_leaks.add_cla_id( "--", btrt_detect_mem_leaks, "=" );
0223 store.add( detect_mem_leaks );
0224
0225
0226
0227 rt::enum_parameter<unit_test::output_format> list_content( btrt_list_content, (
0228 rt::description = "Lists the content of test tree - names of all test suites and test cases.",
0229 rt::env_var = "BOOST_TEST_LIST_CONTENT",
0230 rt::default_value = OF_INVALID,
0231 rt::optional_value = OF_CLF,
0232 rt::enum_values<unit_test::output_format>::value =
0233 #if defined(BOOST_TEST_CLA_NEW_API)
0234 {
0235 { "HRF", OF_CLF },
0236 { "DOT", OF_DOT }
0237 },
0238 #else
0239 rt::enum_values_list<unit_test::output_format>()
0240 ( "HRF", OF_CLF )
0241 ( "DOT", OF_DOT )
0242 ,
0243 #endif
0244 rt::help = "Lists the test suites and cases "
0245 "of the test module instead of executing the test cases. The format of the "
0246 "desired output can be passed to the command. Currently the "
0247 "framework supports two formats: human readable format (HRF) and dot graph "
0248 "format (DOT). If value is omitted HRF value is assumed."
0249 ));
0250 list_content.add_cla_id( "--", btrt_list_content, "=" );
0251 store.add( list_content );
0252
0253
0254
0255 rt::option list_labels( btrt_list_labels, (
0256 rt::description = "Lists all available labels.",
0257 rt::env_var = "BOOST_TEST_LIST_LABELS",
0258 rt::help = "Option " + btrt_list_labels + " instructs the framework to list all the the labels "
0259 "defined in the test module instead of executing the test cases."
0260 ));
0261
0262 list_labels.add_cla_id( "--", btrt_list_labels, "=" );
0263 store.add( list_labels );
0264
0265
0266
0267 rt::enum_parameter<unit_test::output_format> log_format( btrt_log_format, (
0268 rt::description = "Specifies log format.",
0269 rt::env_var = "BOOST_TEST_LOG_FORMAT",
0270 rt::default_value = OF_CLF,
0271 rt::enum_values<unit_test::output_format>::value =
0272 #if defined(BOOST_TEST_CLA_NEW_API)
0273 {
0274 { "HRF", OF_CLF },
0275 { "CLF", OF_CLF },
0276 { "XML", OF_XML },
0277 { "JUNIT", OF_JUNIT },
0278 },
0279 #else
0280 rt::enum_values_list<unit_test::output_format>()
0281 ( "HRF", OF_CLF )
0282 ( "CLF", OF_CLF )
0283 ( "XML", OF_XML )
0284 ( "JUNIT", OF_JUNIT )
0285 ,
0286 #endif
0287 rt::help = "Set the frameowrk's log format to one "
0288 "of the formats supplied by the framework. The only acceptable values for this "
0289 "parameter are the names of the output formats supplied by the framework. By "
0290 "default the framework uses human readable format (HRF) for testing log. This "
0291 "format is similar to compiler error format. Alternatively you can specify XML "
0292 "or JUNIT as log format, which are easier to process by testing automation tools."
0293 ));
0294
0295 log_format.add_cla_id( "--", btrt_log_format, "=" );
0296 log_format.add_cla_id( "-", "f", " " );
0297 store.add( log_format );
0298
0299
0300
0301 rt::enum_parameter<unit_test::log_level> log_level( btrt_log_level, (
0302 rt::description = "Specifies the logging level of the test execution.",
0303 rt::env_var = "BOOST_TEST_LOG_LEVEL",
0304 rt::default_value = log_all_errors,
0305 rt::enum_values<unit_test::log_level>::value =
0306 #if defined(BOOST_TEST_CLA_NEW_API)
0307 {
0308 { "all" , log_successful_tests },
0309 { "success" , log_successful_tests },
0310 { "test_suite" , log_test_units },
0311 { "unit_scope" , log_test_units },
0312 { "message" , log_messages },
0313 { "warning" , log_warnings },
0314 { "error" , log_all_errors },
0315 { "cpp_exception" , log_cpp_exception_errors },
0316 { "system_error" , log_system_errors },
0317 { "fatal_error" , log_fatal_errors },
0318 { "nothing" , log_nothing }
0319 },
0320 #else
0321 rt::enum_values_list<unit_test::log_level>()
0322 ( "all" , log_successful_tests )
0323 ( "success" , log_successful_tests )
0324 ( "test_suite" , log_test_units )
0325 ( "unit_scope" , log_test_units )
0326 ( "message" , log_messages )
0327 ( "warning" , log_warnings )
0328 ( "error" , log_all_errors )
0329 ( "cpp_exception" , log_cpp_exception_errors )
0330 ( "system_error" , log_system_errors )
0331 ( "fatal_error" , log_fatal_errors )
0332 ( "nothing" , log_nothing )
0333 ,
0334 #endif
0335 rt::help = "Set the framework's log level. "
0336 "The log level defines the verbosity of the testing logs produced by a test "
0337 "module. The verbosity ranges from a complete log, when all assertions "
0338 "(both successful and failing) are reported, all notifications about "
0339 "test units start and finish are included, to an empty log when nothing "
0340 "is reported to a testing log stream."
0341 ));
0342
0343 log_level.add_cla_id( "--", btrt_log_level, "=" );
0344 log_level.add_cla_id( "-", "l", " " );
0345 store.add( log_level );
0346
0347
0348
0349 rt::parameter<std::string> log_sink( btrt_log_sink, (
0350 rt::description = "Specifies log sink: stdout (default), stderr or file name.",
0351 rt::env_var = "BOOST_TEST_LOG_SINK",
0352 rt::value_hint = "<stderr|stdout|file name>",
0353 rt::help = "Sets the log sink - the location "
0354 "where Boost.Test writes the logs of the test execution. It allows to easily redirect the "
0355 "test logs to file or standard streams. By default testing log is "
0356 "directed to standard output."
0357 ));
0358
0359 log_sink.add_cla_id( "--", btrt_log_sink, "=" );
0360 log_sink.add_cla_id( "-", "k", " " );
0361 store.add( log_sink );
0362
0363
0364
0365 rt::enum_parameter<unit_test::output_format> output_format( btrt_output_format, (
0366 rt::description = "Specifies output format (both log and report).",
0367 rt::env_var = "BOOST_TEST_OUTPUT_FORMAT",
0368 rt::enum_values<unit_test::output_format>::value =
0369 #if defined(BOOST_TEST_CLA_NEW_API)
0370 {
0371 { "HRF", OF_CLF },
0372 { "CLF", OF_CLF },
0373 { "XML", OF_XML }
0374 },
0375 #else
0376 rt::enum_values_list<unit_test::output_format>()
0377 ( "HRF", OF_CLF )
0378 ( "CLF", OF_CLF )
0379 ( "XML", OF_XML )
0380 ,
0381 #endif
0382 rt::help = "Combines an effect of " + btrt_report_format +
0383 " and " + btrt_log_format + " parameters. If this parameter is specified, "
0384 "it overrides the value of other two parameters. This parameter does not "
0385 "have a default value. The only acceptable values are string names of "
0386 "output formats: HRF - human readable format and XML - XML formats for "
0387 "automation tools processing."
0388 ));
0389
0390 output_format.add_cla_id( "--", btrt_output_format, "=" );
0391 output_format.add_cla_id( "-", "o", " " );
0392 store.add( output_format );
0393
0394
0395
0396 rt::parameter<std::string,rt::REPEATABLE_PARAM> combined_logger( btrt_combined_logger, (
0397 rt::description = "Specifies log level and sink for one or several log format",
0398 rt::env_var = "BOOST_TEST_LOGGER",
0399 rt::value_hint = "log_format,log_level,log_sink[:log_format,log_level,log_sink]",
0400 rt::help = "Specify one or more logging definition, which include the logger type, level and sink. "
0401 "The log format, level and sink follow the same format as for the argument '--" + btrt_log_format +
0402 "', '--" + btrt_log_level + "' and '--" + btrt_log_sink + "' respetively. "
0403 "This command can take several logging definition separated by a ':', or be repeated "
0404 "on the command line."
0405 ));
0406
0407 combined_logger.add_cla_id( "--", btrt_combined_logger, "=" );
0408 store.add( combined_logger );
0409
0410
0411
0412 rt::parameter<unsigned> random_seed( btrt_random_seed, (
0413 rt::description = "Allows to switch between sequential and random order of test units execution."
0414 " Optionally allows to specify concrete seed for random number generator.",
0415 rt::env_var = "BOOST_TEST_RANDOM",
0416 rt::default_value = 0U,
0417 rt::optional_value = 1U,
0418 rt::value_hint = "<seed>",
0419 rt::help = "Instructs the framework to execute the "
0420 "test cases in random order. This parameter accepts an optional unsigned "
0421 "integer argument. If parameter is specified without the argument value testing "
0422 "order is randomized based on current time. Alternatively you can specify "
0423 "any positive value greater than 1 and it will be used as random seed for "
0424 "the run. "
0425 "By default, the test cases are executed in an "
0426 "order defined by their declaration and the optional dependencies among the test units."
0427 ));
0428
0429 random_seed.add_cla_id( "--", btrt_random_seed, "=" );
0430 store.add( random_seed );
0431
0432
0433
0434 rt::enum_parameter<unit_test::output_format> report_format( btrt_report_format, (
0435 rt::description = "Specifies the test report format.",
0436 rt::env_var = "BOOST_TEST_REPORT_FORMAT",
0437 rt::default_value = OF_CLF,
0438 rt::enum_values<unit_test::output_format>::value =
0439 #if defined(BOOST_TEST_CLA_NEW_API)
0440 {
0441 { "HRF", OF_CLF },
0442 { "CLF", OF_CLF },
0443 { "XML", OF_XML }
0444 },
0445 #else
0446 rt::enum_values_list<unit_test::output_format>()
0447 ( "HRF", OF_CLF )
0448 ( "CLF", OF_CLF )
0449 ( "XML", OF_XML )
0450 ,
0451 #endif
0452 rt::help = "Set the framework's report format "
0453 "to one of the formats supplied by the framework. The only acceptable values "
0454 "for this parameter are the names of the output formats. By default the framework "
0455 "uses human readable format (HRF) for results reporting. Alternatively you can "
0456 "specify XML as report format. This format is easier to process by testing "
0457 "automation tools."
0458 ));
0459
0460 report_format.add_cla_id( "--", btrt_report_format, "=" );
0461 report_format.add_cla_id( "-", "m", " " );
0462 store.add( report_format );
0463
0464
0465
0466 rt::enum_parameter<unit_test::report_level> report_level( btrt_report_level, (
0467 rt::description = "Specifies test report level.",
0468 rt::env_var = "BOOST_TEST_REPORT_LEVEL",
0469 rt::default_value = CONFIRMATION_REPORT,
0470 rt::enum_values<unit_test::report_level>::value =
0471 #if defined(BOOST_TEST_CLA_NEW_API)
0472 {
0473 { "confirm", CONFIRMATION_REPORT },
0474 { "short", SHORT_REPORT },
0475 { "detailed", DETAILED_REPORT },
0476 { "no", NO_REPORT }
0477 },
0478 #else
0479 rt::enum_values_list<unit_test::report_level>()
0480 ( "confirm", CONFIRMATION_REPORT )
0481 ( "short", SHORT_REPORT )
0482 ( "detailed", DETAILED_REPORT )
0483 ( "no", NO_REPORT )
0484 ,
0485 #endif
0486 rt::help = "Set the verbosity level of the "
0487 "result report generated by the testing framework. Use value 'no' to "
0488 "disable the results report completely."
0489 ));
0490
0491 report_level.add_cla_id( "--", btrt_report_level, "=" );
0492 report_level.add_cla_id( "-", "r", " " );
0493 store.add( report_level );
0494
0495
0496
0497 rt::parameter<std::string> report_mem_leaks( btrt_report_mem_leaks, (
0498 rt::description = "File where to report memory leaks to.",
0499 rt::env_var = "BOOST_TEST_REPORT_MEMORY_LEAKS_TO",
0500 rt::default_value = std::string(),
0501 rt::value_hint = "<file name>",
0502 rt::help = "Parameter " + btrt_report_mem_leaks + " allows to specify a file where to report "
0503 "memory leaks to. The parameter does not have default value. If it is not specified, "
0504 "memory leaks (if any) are reported to the standard error stream."
0505 ));
0506
0507 report_mem_leaks.add_cla_id( "--", btrt_report_mem_leaks, "=" );
0508 store.add( report_mem_leaks );
0509
0510
0511
0512 rt::parameter<std::string> report_sink( btrt_report_sink, (
0513 rt::description = "Specifies report sink: stderr(default), stdout or file name.",
0514 rt::env_var = "BOOST_TEST_REPORT_SINK",
0515 rt::value_hint = "<stderr|stdout|file name>",
0516 rt::help = "Sets the result report sink - "
0517 "the location where the framework writes the result report to. "
0518 "The sink may be a a file or a standard "
0519 "stream. The default is 'stderr': the "
0520 "standard error stream."
0521 ));
0522
0523 report_sink.add_cla_id( "--", btrt_report_sink, "=" );
0524 report_sink.add_cla_id( "-", "e", " " );
0525 store.add( report_sink );
0526
0527
0528
0529 rt::option result_code( btrt_result_code, (
0530 rt::description = "Disables test modules's result code generation.",
0531 rt::env_var = "BOOST_TEST_RESULT_CODE",
0532 rt::default_value = true,
0533 rt::help = "The 'no' argument value for the parameter " + btrt_result_code + " instructs the "
0534 "framework to always return zero result code. This can be used for test programs "
0535 "executed within IDE. By default this parameter has value 'yes'."
0536 ));
0537
0538 result_code.add_cla_id( "--", btrt_result_code, "=", true );
0539 result_code.add_cla_id( "-", "c", " " );
0540 store.add( result_code );
0541
0542
0543
0544 rt::parameter<std::string,rt::REPEATABLE_PARAM> tests_to_run( btrt_run_filters, (
0545 rt::description = "Filters which tests to execute.",
0546 rt::env_var = "BOOST_TEST_RUN_FILTERS",
0547 rt::value_hint = "<test unit filter>",
0548 rt::help = "Filters which test units to execute. "
0549 "The framework supports both 'selection filters', which allow to select "
0550 "which test units to enable from the set of available test units, and 'disabler "
0551 "filters', which allow to disable some test units. Boost.test also supports "
0552 "enabling/disabling test units at compile time. These settings identify the default "
0553 "set of test units to run. Parameter " + btrt_run_filters + " is used to change this default. "
0554 "This parameter is repeatable, so you can specify more than one filter if necessary."
0555 ));
0556
0557 tests_to_run.add_cla_id( "--", btrt_run_filters, "=" );
0558 tests_to_run.add_cla_id( "-", "t", " " );
0559 store.add( tests_to_run );
0560
0561
0562
0563 rt::option save_test_pattern( btrt_save_test_pattern, (
0564 rt::description = "Allows to switch between saving or matching test pattern file.",
0565 rt::env_var = "BOOST_TEST_SAVE_PATTERN",
0566 rt::help = "Parameter " + btrt_save_test_pattern + " facilitates switching mode of operation for "
0567 "testing output streams.\n\nThis parameter serves no particular purpose within the "
0568 "framework itself. It can be used by test modules relying on output_test_stream to "
0569 "implement testing logic. Default mode is 'match' (false)."
0570 ));
0571
0572 save_test_pattern.add_cla_id( "--", btrt_save_test_pattern, "=" );
0573 store.add( save_test_pattern );
0574
0575
0576
0577 rt::option show_progress( btrt_show_progress, (
0578 rt::description = "Turns on progress display.",
0579 rt::env_var = "BOOST_TEST_SHOW_PROGRESS",
0580 rt::help = "Instructs the framework to display the progress of the tests. "
0581 "This feature is turned off by default."
0582 ));
0583
0584 show_progress.add_cla_id( "--", btrt_show_progress, "=" );
0585 show_progress.add_cla_id( "-", "p", " " );
0586 store.add( show_progress );
0587
0588
0589
0590 rt::option use_alt_stack( btrt_use_alt_stack, (
0591 rt::description = "Turns on/off usage of an alternative stack for signal handling.",
0592 rt::env_var = "BOOST_TEST_USE_ALT_STACK",
0593 rt::default_value = true,
0594 rt::help = "Instructs the framework to use an alternative "
0595 "stack for operating system's signals handling (on platforms where this is supported). "
0596 "The feature is enabled by default, but can be disabled using this command line switch."
0597 ));
0598
0599 use_alt_stack.add_cla_id( "--", btrt_use_alt_stack, "=", true );
0600 store.add( use_alt_stack );
0601
0602
0603
0604 rt::option wait_for_debugger( btrt_wait_for_debugger, (
0605 rt::description = "Forces test module to wait for button to be pressed before starting test run.",
0606 rt::env_var = "BOOST_TEST_WAIT_FOR_DEBUGGER",
0607 rt::help = "Instructs the framework to pause before starting "
0608 "test units execution, so that you can attach a debugger to the test module process. "
0609 "This feature is turned off by default."
0610 ));
0611
0612 wait_for_debugger.add_cla_id( "--", btrt_wait_for_debugger, "=" );
0613 wait_for_debugger.add_cla_id( "-", "w", " " );
0614 store.add( wait_for_debugger );
0615
0616
0617
0618 rt::parameter<std::string> help( btrt_help, (
0619 rt::description = "Help for framework parameters.",
0620 rt::optional_value = std::string(),
0621 rt::value_hint = "<parameter name>",
0622 rt::help = "Displays help on the framework's parameters. "
0623 "The parameter accepts an optional argument value. If present, an argument value is "
0624 "interpreted as a parameter name (name guessing works as well, so for example "
0625 "'--help=rand' displays help on the parameter 'random'). If the parameter name is unknown "
0626 "or ambiguous error is reported. If argument value is absent, a summary of all "
0627 "framework's parameter is displayed."
0628 ));
0629 help.add_cla_id( "--", btrt_help, "=" );
0630 store.add( help );
0631
0632
0633
0634 rt::option usage( btrt_usage, (
0635 rt::description = "Short message explaining usage of Boost.Test parameters."
0636 ));
0637 usage.add_cla_id( "-", "?", " " );
0638 store.add( usage );
0639
0640
0641
0642 rt::option version( btrt_version, (
0643 rt::description = "Prints Boost.Test version and exits."
0644 ));
0645 version.add_cla_id( "--", btrt_version, " " );
0646 store.add( version );
0647 }
0648
0649 static rt::arguments_store s_arguments_store;
0650 static rt::parameters_store s_parameters_store;
0651
0652
0653
0654 }
0655
0656 void
0657 init( int& argc, char** argv )
0658 {
0659 shared_ptr<rt::cla::parser> parser;
0660
0661 BOOST_TEST_I_TRY {
0662
0663 if( s_parameters_store.is_empty() )
0664 register_parameters( s_parameters_store );
0665
0666
0667 s_arguments_store.clear();
0668
0669
0670 parser.reset( new rt::cla::parser( s_parameters_store, (rt::end_of_params = "--", rt::negation_prefix = "no_") ) );
0671 argc = parser->parse( argc, argv, s_arguments_store );
0672
0673
0674 rt::env::fetch_absent( s_parameters_store, s_arguments_store );
0675
0676
0677 rt::finalize_arguments( s_parameters_store, s_arguments_store );
0678
0679
0680 bool use_color = true;
0681 if( s_arguments_store.has(btrt_color_output ) ) {
0682 use_color = runtime_config::get<bool>(runtime_config::btrt_color_output);
0683 }
0684
0685
0686 if( runtime_config::get<bool>( btrt_version ) ) {
0687 parser->version( std::cerr );
0688 BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
0689 }
0690 else if( runtime_config::get<bool>( btrt_usage ) ) {
0691 parser->usage( std::cerr, runtime::cstring(), use_color );
0692 BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
0693 }
0694 else if( s_arguments_store.has( btrt_help ) ) {
0695 parser->help(std::cerr,
0696 s_parameters_store,
0697 runtime_config::get<std::string>( btrt_help ),
0698 use_color );
0699 BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
0700 }
0701
0702
0703 if( s_arguments_store.has( btrt_output_format ) ) {
0704 unit_test::output_format of = s_arguments_store.get<unit_test::output_format>( btrt_output_format );
0705 s_arguments_store.set( btrt_report_format, of );
0706 s_arguments_store.set( btrt_log_format, of );
0707 }
0708
0709 }
0710 BOOST_TEST_I_CATCH( rt::init_error, ex ) {
0711 BOOST_TEST_SETUP_ASSERT( false, ex.msg );
0712 }
0713 BOOST_TEST_I_CATCH( rt::ambiguous_param, ex ) {
0714 std::cerr << ex.msg << "\n Did you mean one of these?\n";
0715
0716 BOOST_TEST_FOREACH( rt::cstring, name, ex.m_amb_candidates )
0717 std::cerr << " " << name << "\n";
0718
0719 BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_exception_failure ) );
0720 }
0721 BOOST_TEST_I_CATCH( rt::unrecognized_param, ex ) {
0722 std::cerr << ex.msg << "\n";
0723
0724 if( !ex.m_typo_candidates.empty() ) {
0725 std::cerr << " Did you mean one of these?\n";
0726
0727 BOOST_TEST_FOREACH( rt::cstring, name, ex.m_typo_candidates )
0728 std::cerr << " " << name << "\n";
0729 }
0730 else if( parser ) {
0731 std::cerr << "\n";
0732 parser->usage( std::cerr );
0733 }
0734
0735 BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_exception_failure ) );
0736 }
0737 BOOST_TEST_I_CATCH( rt::input_error, ex ) {
0738 std::cerr << ex.msg << "\n\n";
0739
0740 if( parser )
0741 parser->usage( std::cerr, ex.param_name );
0742
0743 BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_exception_failure ) );
0744 }
0745 }
0746
0747
0748
0749 rt::arguments_store const&
0750 argument_store()
0751 {
0752 return s_arguments_store;
0753 }
0754
0755
0756
0757 bool
0758 save_pattern()
0759 {
0760 return runtime_config::get<bool>( btrt_save_test_pattern );
0761 }
0762
0763
0764
0765 }
0766 }
0767 }
0768
0769 #include <boost/test/detail/enable_warnings.hpp>
0770
0771 #endif