From f48ab1b286fedf53af9d824c874f4661a18fc76d Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 7 Aug 2013 15:34:13 -0700 Subject: [PATCH] Add 'print' unit test which prints the list of tests --- Notes/VFALCO_LOG.txt | 8 ++++ .../diagnostic/beast_ProtectedCall.cpp | 6 +-- .../beast_core/diagnostic/beast_UnitTest.cpp | 43 +++++++++++++++++++ .../network/ripple_ProxyHandshake.cpp | 2 +- 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/Notes/VFALCO_LOG.txt b/Notes/VFALCO_LOG.txt index 6e87fdd03b..2cba1105e7 100644 --- a/Notes/VFALCO_LOG.txt +++ b/Notes/VFALCO_LOG.txt @@ -1,5 +1,13 @@ Vinnie Falco's Change Log +2013/08/07 + +- Add 'print' test that shows all the tests + +2013/08/04 + +- Begin reworking of socket code + 2013/08/01 - Add beast::SemanticVersion diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_ProtectedCall.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_ProtectedCall.cpp index 0227a3c2a0..d54ff4a62e 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_ProtectedCall.cpp +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_ProtectedCall.cpp @@ -323,11 +323,11 @@ public: { beginTestCase ("backtrace"); - pass (); - String const s = SystemStats::getStackBacktrace (); - Logger::outputDebugString (s); + logMessage (s); + + pass (); } }; diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp index 0c5d1802e6..f905b8adcf 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp @@ -351,3 +351,46 @@ void UnitTests::runTest (UnitTest& test) Throw (std::runtime_error ("unhandled exception during unit tests")); } } + +//------------------------------------------------------------------------------ + +/** A UnitTest that prints the list of available unit tests. + Not an actual test (it always passes) but if you run it manually it + will print a list of the names of all available unit tests in the program. +*/ +class UnitTestsPrinter : public UnitTest +{ +public: + UnitTestsPrinter () : UnitTest ("print", "print", runManual) + { + } + + void runTest () + { + beginTestCase ("List available unit tests"); + + TestList const& list (UnitTest::getAllTests ()); + + for (int i = 0; i < list.size (); ++i) + { + UnitTest const& test (*list [i]); + + String s; + switch (test.getWhen ()) + { + default: + case UnitTest::runNormal: s << " "; break; + case UnitTest::runManual: s << "[manual] "; break; + case UnitTest::runStartup: s << "[FORCED] "; break; + }; + + s << test.getPackageName () << "/" << test.getClassName (); + + logMessage (s); + } + + pass (); + } +}; + +static UnitTestsPrinter unitTestsPrinter; diff --git a/modules/ripple_app/network/ripple_ProxyHandshake.cpp b/modules/ripple_app/network/ripple_ProxyHandshake.cpp index c3dba646ee..2cd92a6591 100644 --- a/modules/ripple_app/network/ripple_ProxyHandshake.cpp +++ b/modules/ripple_app/network/ripple_ProxyHandshake.cpp @@ -269,7 +269,7 @@ bool ProxyHandshake::Version1::parse (void const* headerData, size_t headerBytes class ProxyHandshakeTests : public UnitTest { public: - ProxyHandshakeTests () : UnitTest ("ProxyHandshake", "ripple", runManual) + ProxyHandshakeTests () : UnitTest ("ProxyHandshake", "ripple") { }