diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2009-01-18 18:03:32 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2009-01-18 18:03:32 (GMT) |
commit | 7e1ba9d0757885626b1ed9a26a0b014d6755429b (patch) | |
tree | 5b9ed6590a34c24a07d5b39bfe5a267f7e28df13 /Source/cmCTest.cxx | |
parent | e4048118dea476a018d1944771e0c95b8805ec21 (diff) | |
download | CMake-7e1ba9d0757885626b1ed9a26a0b014d6755429b.zip CMake-7e1ba9d0757885626b1ed9a26a0b014d6755429b.tar.gz CMake-7e1ba9d0757885626b1ed9a26a0b014d6755429b.tar.bz2 |
BUG: add output on failure to ctest #8255
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r-- | Source/cmCTest.cxx | 26 |
1 files changed, 26 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); +} + |