diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-01-26 16:13:12 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-01-26 16:13:12 (GMT) |
commit | f6cd83d6f3dfad07cedf82e96eb371fa264abef2 (patch) | |
tree | ac03f9801cd8e5510daeb18a43f7db02827e3acd | |
parent | f7063fc6612ad461e0d1a6dbc5a6da2366c0812e (diff) | |
download | CMake-f6cd83d6f3dfad07cedf82e96eb371fa264abef2.zip CMake-f6cd83d6f3dfad07cedf82e96eb371fa264abef2.tar.gz CMake-f6cd83d6f3dfad07cedf82e96eb371fa264abef2.tar.bz2 |
ENH: Add support for shrinking the output of the test
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 77 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 6 |
2 files changed, 83 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 5839ac7..60e6b94 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -198,6 +198,9 @@ cmCTestTestHandler::cmCTestTestHandler() m_UseIncludeRegExp = false; m_UseExcludeRegExp = false; m_UseExcludeRegExpFirst = false; + + m_CustomMaximumPassedTestOutputSize = 1 * 1024; + m_CustomMaximumFailedTestOutputSize = 300 * 1024; } //---------------------------------------------------------------------- @@ -218,6 +221,12 @@ void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf) cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_MEMCHECK_IGNORE", m_CustomMemCheckIgnore); + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE", + m_CustomMaximumPassedTestOutputSize); + cmCTest::PopulateCustomInteger(mf, + "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE", + m_CustomMaximumFailedTestOutputSize); } @@ -647,6 +656,15 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, } } + if ( cres.m_Status == cmCTestTestHandler::COMPLETED ) + { + this->CleanTestOutput(output, static_cast<size_t>(m_CustomMaximumPassedTestOutputSize)); + } + else + { + this->CleanTestOutput(output, static_cast<size_t>(m_CustomMaximumFailedTestOutputSize)); + } + cres.m_Output = output; cres.m_ReturnValue = retVal; cres.m_CompletionStatus = "Completed"; @@ -1640,3 +1658,62 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in) } } +bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t remove_threshold) +{ + if ( remove_threshold == 0 ) + { + return true; + } + if ( output.find("CTEST_FULL_OUTPUT") != output.npos ) + { + return true; + } + cmOStringStream ostr; + std::string::size_type cc; + std::string::size_type skipsize; + int inTag = 0; + int skipped = 0; + for ( cc = 0; cc < output.size(); cc ++ ) + { + int ch = output[cc]; + if ( ch < 0 || ch > 255 ) + { + break; + } + if ( ch == '<' ) + { + inTag = 1; + } + if ( !inTag ) + { + int notskip = 0; + // Skip + if ( skipsize < remove_threshold ) + { + ostr << static_cast<char>(ch); + notskip = 1; + } + skipsize ++; + if ( notskip && skipsize >= remove_threshold ) + { + skipped = 1; + } + } + else + { + ostr << static_cast<char>(ch); + } + if ( ch == '>' ) + { + inTag = 0; + } + } + if ( skipped ) + { + ostr << "..." << std::endl << "The rest of the test output was removed since it exceeds the threshold of " + << remove_threshold << " characters." << std::endl; + } + output = ostr.str(); + return true; +} + diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 4bca7d0..1c417a2 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -189,6 +189,9 @@ private: std::vector<cmStdString> m_CustomTestsIgnore; std::vector<cmStdString> m_CustomMemCheckIgnore; + int m_CustomMaximumPassedTestOutputSize; + int m_CustomMaximumFailedTestOutputSize; + std::string m_StartTest; std::string m_EndTest; double m_ElapsedTestingTime; @@ -212,6 +215,9 @@ private: bool ProcessMemCheckPurifyOutput(const std::string& str, std::string& log, int* results); + //! Clean test output to specified length + bool CleanTestOutput(std::string& output, size_t length); + std::string TestsToRunString; bool m_UseUnion; }; |