From b15cbb3cdc26a000f138c78a086f8d9f25088b3c Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 18 May 2012 12:35:40 -0700 Subject: [PATCH] Fix --test argument passing. --- src/main.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 46b066400f..90ff261bb6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,6 +59,7 @@ int main(int argc, char* argv[]) { int iResult = 0; po::variables_map vm; // Map of options. + bool bTest = false; // // Set up option parsing. @@ -86,9 +87,16 @@ int main(int argc, char* argv[]) iResult = 2; } - // Parse options, if no error. - if (!iResult) + if (iResult) { + nothing(); + } + else if (argc >= 2 && !strcmp(argv[1], "--test")) { + bTest = true; + } + else + { + // Parse options, if no error. po::store(po::command_line_parser(argc, argv) .options(desc) // Parse options. .positional(p) // Remainder as --parameters. @@ -107,22 +115,20 @@ int main(int argc, char* argv[]) } else if (vm.count("test")) { - int iCmd = vm.count("parameters"); + std::cerr << "--test must be first parameter." << std::endl; + iResult = 1; + } + else if (bTest) + { std::vector pvCmd; + // Copy all but "--test" at argv[1]. pvCmd.push_back(argv[0]); - if (iCmd) - { - std::vector vCmd; + for (int i=1; i++ != argc; ) + pvCmd.push_back(argv[i]); - vCmd = vm["parameters"].as >(); - - BOOST_FOREACH(std::string& param, vCmd) - pvCmd.push_back(const_cast(param.c_str())); - } - - iResult = unit_test_main(init_unit_test, iCmd, &pvCmd[0]); + iResult = unit_test_main(init_unit_test, pvCmd.size()-1, &pvCmd[0]); } else if (!vm.count("parameters")) {