From 52133569f5035c69ba9d53bf7001a4e6d73e811f 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 +++++++++++++------ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/modules/beast_core/diagnostic/beast_UnitTest.cpp b/modules/beast_core/diagnostic/beast_UnitTest.cpp index 3efc30014..285d4e019 100644 --- a/modules/beast_core/diagnostic/beast_UnitTest.cpp +++ b/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/modules/beast_core/diagnostic/beast_UnitTest.h b/modules/beast_core/diagnostic/beast_UnitTest.h index 1f950d9d8..e1c1527fd 100644 --- a/modules/beast_core/diagnostic/beast_UnitTest.h +++ b/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);