Permalink
Browse files

Change unit test --help output.

Before:
-------------------------------------------------------------------------------
Usage: test/unit/ut-filestream [TEST_NAME] [OPTION]...
Available tests:
  memory [block-factor = 1]
Run unit test
  -h, --help                         Show this help message
  -l, --log-level LEVEL              Output log to standard output
  -e, --log-level-on-error LEVEL     Output log when a test fails
  -v, --verbose                      Alias of --log-level info
  -d, --debug                        Alias of --log-level debug
  -V, --version                      Show version information
      --memory SIZE                  Set memory limit (default: 50)
-------------------------------------------------------------------------------

Now:
-------------------------------------------------------------------------------
Usage: test/unit/ut-filestream [TEST_NAME] [OPTION]...
Run the given unit test.

Available tests:
  memory [--block-factor ARG (= 1)]

Mandatory arguments to long options are mandatory for short options too.
  -h, --help                         Show this help message
  -l, --log-level LEVEL              Output log to standard output
  -e, --log-level-on-error LEVEL     Output log when a test fails
  -v, --verbose                      Alias of --log-level info
  -d, --debug                        Alias of --log-level debug
  -V, --version                      Show version information
      --memory MB                    Set memory limit (default: 50 MB)

LEVEL may be one of the following:
fatal, error, warn, info, app_debug, debug, mem_debug

When TEST_NAME is "all", all tests are run, and log level defaults to "error".
When running just a single test, the default log level is "info".
-------------------------------------------------------------------------------
  • Loading branch information...
1 parent d65748c commit 927e97197401da3f12de60d997938bbe8f593a52 @Mortal Mortal committed Aug 7, 2012
Showing with 13 additions and 4 deletions.
  1. +11 −3 tpie/unittest.cpp
  2. +2 −1 tpie/unittest.h
View
14 tpie/unittest.cpp
@@ -228,19 +228,27 @@ void tests::build_information(std::ostream & o) {
void tests::show_usage(std::ostream & o) {
o << "Usage: " << exe_name << " [TEST_NAME] [OPTION]..." << std::endl;
+ o << "Run the given unit test.\n\n";
o << "Available tests:" << std::endl;
for (size_t i = 0; i < m_tests.size(); ++i) {
o << " " << m_tests[i] << std::endl;
}
- o << "Run unit test" << std::endl;
+ o << '\n';
+ o << "Mandatory arguments to long options are mandatory for short options too.\n";
o << " -h, --help Show this help message" << std::endl;
o << " -l, --log-level LEVEL Output log to standard output" << std::endl;
o << " -e, --log-level-on-error LEVEL Output log when a test fails" << std::endl;
o << " -v, --verbose Alias of --log-level info" << std::endl;
o << " -d, --debug Alias of --log-level debug" << std::endl;
o << " -V, --version Show version information" << std::endl;
- o << " --memory SIZE Set memory limit (default: "
- << memory_limit << ")" << std::endl;
+ o << " --memory MB Set memory limit (default: "
+ << memory_limit << " MB)\n\n";
+
+ o << "LEVEL may be one of the following:\n";
+ o << "fatal, error, warn, info, app_debug, debug, mem_debug\n\n";
+
+ o << "When TEST_NAME is \"all\", all tests are run, and log level defaults to \"error\".\n";
+ o << "When running just a single test, the default log level is \"info\".\n";
}
tests::operator int() {
View
3 tpie/unittest.h
@@ -317,7 +317,8 @@ T tests::get_arg(const std::string & name, T def) const {
template <typename T>
std::string tests::arg_str(const std::string & name, T def) const {
- return std::string(" [")+name+" = "+magic_cast<std::string>(def)+"]";
+ std::string dashes((name.size() == 1) ? 1 : 2, '-');
+ return std::string(" [")+dashes+name+" ARG (= "+magic_cast<std::string>(def)+")]";
}
template <typename T>

0 comments on commit 927e971

Please sign in to comment.