summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestTestHandler.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CTest/cmCTestTestHandler.cxx')
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx84
1 files changed, 36 insertions, 48 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 6dd348d..87c75eb 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -26,6 +26,7 @@
#include "cmCommand.h"
#include "cmSystemTools.h"
#include "cmXMLSafe.h"
+#include "cm_utf8.h"
#include <stdlib.h>
#include <math.h>
@@ -438,6 +439,8 @@ void cmCTestTestHandler::Initialize()
this->TestsToRun.clear();
+ this->UseIncludeLabelRegExpFlag = false;
+ this->UseExcludeLabelRegExpFlag = false;
this->UseIncludeRegExpFlag = false;
this->UseExcludeRegExpFlag = false;
this->UseExcludeRegExpFirst = false;
@@ -1978,65 +1981,45 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in)
}
}
-//----------------------------------------------------------------------
-bool cmCTestTestHandler::CleanTestOutput(std::string& output,
- size_t remove_threshold)
+//----------------------------------------------------------------------------
+bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
{
- if ( remove_threshold == 0 )
+ if(!length || length >= output.size() ||
+ output.find("CTEST_FULL_OUTPUT") != output.npos)
{
return true;
}
- if ( output.find("CTEST_FULL_OUTPUT") != output.npos )
+
+ // Truncate at given length but do not break in the middle of a multi-byte
+ // UTF-8 encoding.
+ char const* const begin = output.c_str();
+ char const* const end = begin + output.size();
+ char const* const truncate = begin + length;
+ char const* current = begin;
+ while(current < truncate)
{
- return true;
- }
- cmOStringStream ostr;
- std::string::size_type cc;
- std::string::size_type skipsize = 0;
- 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 )
+ unsigned int ch;
+ if(const char* next = cm_utf8_decode_character(current, end, &ch))
{
- int notskip = 0;
- // Skip
- if ( skipsize < remove_threshold )
+ if(next > truncate)
{
- ostr << static_cast<char>(ch);
- notskip = 1;
- }
- skipsize ++;
- if ( notskip && skipsize >= remove_threshold )
- {
- skipped = 1;
+ break;
}
+ current = next;
}
- else
- {
- ostr << static_cast<char>(ch);
- }
- if ( ch == '>' )
+ else // Bad byte will be handled by cmXMLSafe.
{
- inTag = 0;
+ ++current;
}
}
- 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();
+ output = output.substr(0, current - begin);
+
+ // Append truncation message.
+ cmOStringStream msg;
+ msg << "...\n"
+ "The rest of the test output was removed since it exceeds the threshold "
+ "of " << length << " bytes.\n";
+ output += msg.str();
return true;
}
@@ -2120,6 +2103,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "TIMEOUT" )
{
rtit->Timeout = atof(val.c_str());
+ rtit->ExplicitTimeout = true;
}
if ( key == "COST" )
{
@@ -2190,7 +2174,6 @@ bool cmCTestTestHandler::SetTestsProperties(
{
rtit->Labels.push_back(*crit);
}
-
}
if ( key == "MEASUREMENT" )
{
@@ -2219,6 +2202,10 @@ bool cmCTestTestHandler::SetTestsProperties(
std::string(crit->c_str())));
}
}
+ if ( key == "WORKING_DIRECTORY" )
+ {
+ rtit->Directory = val;
+ }
}
}
}
@@ -2290,6 +2277,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.WillFail = false;
test.RunSerial = false;
test.Timeout = 0;
+ test.ExplicitTimeout = false;
test.Cost = 0;
test.Processors = 1;
test.PreviousRuns = 0;