Browse Source

Allow test runs to be non-verbose.

Daniel Buckmaster 11 years ago
parent
commit
d02cc94edd
1 changed files with 14 additions and 7 deletions
  1. 14 7
      Engine/source/testing/unitTesting.cpp

+ 14 - 7
Engine/source/testing/unitTesting.cpp

@@ -36,8 +36,9 @@ class TorqueUnitTestListener : public ::testing::EmptyTestEventListener
    // Called before a test starts.
    // Called before a test starts.
    virtual void OnTestStart( const ::testing::TestInfo& testInfo )
    virtual void OnTestStart( const ::testing::TestInfo& testInfo )
    {
    {
-      Con::printf("> Starting Test '%s.%s'",
-         testInfo.test_case_name(), testInfo.name());
+      if( mVerbose )
+         Con::printf("> Starting Test '%s.%s'",
+            testInfo.test_case_name(), testInfo.name());
    }
    }
 
 
    // Called after a failed assertion or a SUCCEED() invocation.
    // Called after a failed assertion or a SUCCEED() invocation.
@@ -45,13 +46,13 @@ class TorqueUnitTestListener : public ::testing::EmptyTestEventListener
    {
    {
       if ( testPartResult.failed() )
       if ( testPartResult.failed() )
       {
       {
-         Con::warnf(">> Failed with '%s' in '%s' at (line:%d)",
+         Con::warnf(">> Failed with '%s' in '%s' at (line:%d)\n",
             testPartResult.summary(),
             testPartResult.summary(),
             testPartResult.file_name(),
             testPartResult.file_name(),
             testPartResult.line_number()
             testPartResult.line_number()
             );
             );
       }
       }
-      else
+      else if( mVerbose )
       {
       {
          Con::printf(">> Passed with '%s' in '%s' at (line:%d)",
          Con::printf(">> Passed with '%s' in '%s' at (line:%d)",
             testPartResult.summary(),
             testPartResult.summary(),
@@ -64,9 +65,15 @@ class TorqueUnitTestListener : public ::testing::EmptyTestEventListener
    // Called after a test ends.
    // Called after a test ends.
    virtual void OnTestEnd( const ::testing::TestInfo& testInfo )
    virtual void OnTestEnd( const ::testing::TestInfo& testInfo )
    {
    {
-      Con::printf("> Ending Test '%s.%s'\n",
-         testInfo.test_case_name(), testInfo.name());
+      if( mVerbose )
+         Con::printf("> Ending Test '%s.%s'\n",
+            testInfo.test_case_name(), testInfo.name());
    }
    }
+
+   bool mVerbose;
+
+public:
+   TorqueUnitTestListener( bool verbose ) : mVerbose( verbose ) {}
 };
 };
 
 
 DefineConsoleFunction( runAllUnitTests, int, (const char* testSpecs), (""),
 DefineConsoleFunction( runAllUnitTests, int, (const char* testSpecs), (""),
@@ -113,7 +120,7 @@ DefineConsoleFunction( runAllUnitTests, int, (const char* testSpecs), (""),
    }
    }
 
 
    // Add the Torque unit test listener.
    // Add the Torque unit test listener.
-   listeners.Append( new TorqueUnitTestListener );
+   listeners.Append( new TorqueUnitTestListener(false) );
 
 
    // Perform googletest run.
    // Perform googletest run.
    Con::printf( "\nUnit Tests Starting...\n" );
    Con::printf( "\nUnit Tests Starting...\n" );