BUG: add output on failure to ctest #8255
This commit is contained in:
parent
e4048118de
commit
7e1ba9d075
|
@ -258,6 +258,11 @@ cmCTest::cmCTest()
|
|||
this->OutputLogFileLastTag = -1;
|
||||
this->SuppressUpdatingCTestConfiguration = false;
|
||||
this->DartVersion = 1;
|
||||
this->OutputTestOutputOnTestFailure = false;
|
||||
if(cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE"))
|
||||
{
|
||||
this->OutputTestOutputOnTestFailure = true;
|
||||
}
|
||||
this->InitStreams();
|
||||
|
||||
this->Parts[PartStart].SetName("Start");
|
||||
|
@ -1233,9 +1238,17 @@ int cmCTest::RunTest(std::vector<const char*> argv,
|
|||
if(result == cmsysProcess_State_Exited)
|
||||
{
|
||||
*retVal = cmsysProcess_GetExitValue(cp);
|
||||
if(*retVal != 0 && this->OutputTestOutputOnTestFailure)
|
||||
{
|
||||
OutputTestErrors(tempOutput);
|
||||
}
|
||||
}
|
||||
else if(result == cmsysProcess_State_Exception)
|
||||
{
|
||||
if(this->OutputTestOutputOnTestFailure)
|
||||
{
|
||||
OutputTestErrors(tempOutput);
|
||||
}
|
||||
*retVal = cmsysProcess_GetExitException(cp);
|
||||
std::string outerr = "\n*** Exception executing: ";
|
||||
outerr += cmsysProcess_GetExceptionString(cp);
|
||||
|
@ -1767,6 +1780,10 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
|
|||
this->ExtraVerbose = true;
|
||||
this->Verbose = true;
|
||||
}
|
||||
if(this->CheckArgument(arg, "--output-on-failure"))
|
||||
{
|
||||
this->OutputTestOutputOnTestFailure = true;
|
||||
}
|
||||
|
||||
if(this->CheckArgument(arg, "-N", "--show-only"))
|
||||
{
|
||||
|
@ -2746,3 +2763,12 @@ double cmCTest::GetRemainingTimeAllowed()
|
|||
|
||||
return ch->GetRemainingTimeAllowed();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void cmCTest::OutputTestErrors(std::vector<char> const &process_output)
|
||||
{
|
||||
std::string test_outputs("\n*** Test Failed:\n");
|
||||
test_outputs.append(&*process_output.begin(), process_output.size());
|
||||
cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
|
||||
}
|
||||
|
||||
|
|
|
@ -467,6 +467,9 @@ private:
|
|||
bool CheckArgument(const std::string& arg, const char* varg1,
|
||||
const char* varg2 = 0);
|
||||
|
||||
//! Output errors from a test
|
||||
void OutputTestErrors(std::vector<char> const &process_output);
|
||||
|
||||
bool SuppressUpdatingCTestConfiguration;
|
||||
|
||||
bool Debug;
|
||||
|
@ -482,6 +485,8 @@ private:
|
|||
|
||||
cmGeneratedFileStream* OutputLogFile;
|
||||
int OutputLogFileLastTag;
|
||||
|
||||
bool OutputTestOutputOnTestFailure;
|
||||
};
|
||||
|
||||
class cmCTestLogWrite
|
||||
|
|
|
@ -65,6 +65,9 @@ static const char * cmDocumentationOptions[][3] =
|
|||
{"--debug", "Displaying more verbose internals of CTest.",
|
||||
"This feature will result in large number of output that is mostly "
|
||||
"useful for debugging dashboard problems."},
|
||||
{"--output-on-failure", "Output anything outputted by the test program "
|
||||
"if the test should fail. This option can also be enabled by setting "
|
||||
"the environment variable CTEST_OUTPUT_ON_FAILURE"},
|
||||
{"-Q,--quiet", "Make ctest quiet.",
|
||||
"This option will suppress all the output. The output log file will "
|
||||
"still be generated if the --output-log is specified. Options such "
|
||||
|
|
Loading…
Reference in New Issue