summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-01-18 18:03:32 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2009-01-18 18:03:32 (GMT)
commit7e1ba9d0757885626b1ed9a26a0b014d6755429b (patch)
tree5b9ed6590a34c24a07d5b39bfe5a267f7e28df13 /Source
parente4048118dea476a018d1944771e0c95b8805ec21 (diff)
downloadCMake-7e1ba9d0757885626b1ed9a26a0b014d6755429b.zip
CMake-7e1ba9d0757885626b1ed9a26a0b014d6755429b.tar.gz
CMake-7e1ba9d0757885626b1ed9a26a0b014d6755429b.tar.bz2
BUG: add output on failure to ctest #8255
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCTest.cxx26
-rw-r--r--Source/cmCTest.h5
-rw-r--r--Source/ctest.cxx3
3 files changed, 34 insertions, 0 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 4116d35..1853996 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -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);
+}
+
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index d822fec..b949378 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -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
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 9401574..7f4987e 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -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 "