From 290627d7417668c45e2ae00150623001c2193aab Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 1 Aug 2013 14:25:20 -0700 Subject: [PATCH] Add runStartup category to UnitTest --- .../beast_core/diagnostic/beast_UnitTest.cpp | 27 ++++++++++++-- .../beast_core/diagnostic/beast_UnitTest.h | 35 +++++++++++++------ modules/ripple_app/node/ripple_NodeStore.cpp | 2 +- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp index 3efc30014c..285d4e019c 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp @@ -258,7 +258,28 @@ void UnitTests::runAllTests () { UnitTest* const test = allTests [i]; - if (test->getWhen () == UnitTest::runAlways) + if (test->getWhen () == UnitTest::runNormal) + { + tests.add (test); + } + } + + runTests (tests); +} + +void UnitTests::runStartupTests () +{ + UnitTest::TestList const& allTests (UnitTest::getAllTests ()); + + Array tests; + + tests.ensureStorageAllocated (allTests.size ()); + + for (int i = 0; i < allTests.size(); ++i) + { + UnitTest* const test = allTests [i]; + + if (test->getWhen () == UnitTest::runStartup) { tests.add (test); } @@ -279,7 +300,9 @@ void UnitTests::runTestsByName (String const& name) { UnitTest* const test = allTests [i]; - if (test->getPackageName () == name && test->getWhen () == UnitTest::runAlways) + if (test->getPackageName () == name && + (test->getWhen () == UnitTest::runNormal || + test->getWhen () == UnitTest::runStartup)) { tests.add (test); } diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h index 1f950d9d82..e1c1527fdf 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.h @@ -67,16 +67,28 @@ class UnitTests; class BEAST_API UnitTest : public Uncopyable { public: - /** When the test should be run. - - Tests that run always will be incuded in all tests or in a group test. - Manual tests will only run when they are individually targeted. This - lets you leave out slow tests or peformance tests from the main test set. - */ + /** When the test should be run. */ enum When { - runAlways, - runManual + /** Test will be run when @ref runAllTests is called. + @see runAllTests + */ + runNormal, + + /** Test will excluded from @ref runAllTests. + The test can be manually run from @ref runTestsByName. + @see runAllTests, runTestsByName + */ + runManual, + + /** Test will be additionlly forced to run on every launch. + If any failures occur, FatalError is called. The tests will + also be run from @ref runAllTests or @ref runTestsByName if + explicitly invoked. + + @see FatalError + */ + runStartup }; /** Describes a single test item. @@ -172,7 +184,7 @@ public: */ explicit UnitTest (String const& name, String const& group = "", - When when = runAlways); + When when = runNormal); /** Destructor. */ virtual ~UnitTest(); @@ -358,10 +370,13 @@ public: void runTests (Array const& tests); /** Runs all the UnitTest objects that currently exist. - This calls runTests() for all the objects listed in UnitTest::getAllTests(). + This calls @ref runTests for all the objects listed in @ref UnitTest::getAllTests. */ void runAllTests (); + /** Runs the startup tests. */ + void runStartupTests (); + /** Run a particular test or group. */ void runTestsByName (String const& name); diff --git a/modules/ripple_app/node/ripple_NodeStore.cpp b/modules/ripple_app/node/ripple_NodeStore.cpp index 1b123387ef..4b01b60173 100644 --- a/modules/ripple_app/node/ripple_NodeStore.cpp +++ b/modules/ripple_app/node/ripple_NodeStore.cpp @@ -605,7 +605,7 @@ public: }; public: - NodeStoreUnitTest (String name, UnitTest::When when = UnitTest::runAlways) + NodeStoreUnitTest (String name, UnitTest::When when = UnitTest::runNormal) : UnitTest (name, "ripple", when) { }