From 7435355ec8ca10d3d6ef07d975e1f0d9a60b681d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 12 Feb 2009 13:00:22 -0500 Subject: ENH: Report file names relative to source dir This teaches cmCTestLaunch to report source files that lie under the top source directory relative to the top. --- Source/CTest/cmCTestBuildHandler.cxx | 13 +++++++++--- Source/CTest/cmCTestLaunch.cxx | 39 +++++++++++++++++++++++++++++++++++- Source/CTest/cmCTestLaunch.h | 4 ++++ 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index a576960ae7..d85df86167 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -752,7 +752,7 @@ private: cmCTestBuildHandler* Handler; cmCTest* CTest; - void WriteScrapeMatchers(); + void WriteLauncherConfig(); void WriteScrapeMatchers(const char* purpose, std::vector const& matchers); }; @@ -784,7 +784,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler): { // Enable launcher fragments. cmSystemTools::MakeDirectory(launchDir.c_str()); - this->WriteScrapeMatchers(); + this->WriteLauncherConfig(); std::string launchEnv = "CTEST_LAUNCH_LOGS="; launchEnv += launchDir; cmSystemTools::PutEnv(launchEnv.c_str()); @@ -808,12 +808,19 @@ cmCTestBuildHandler::LaunchHelper::~LaunchHelper() } //---------------------------------------------------------------------------- -void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers() +void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig() { this->WriteScrapeMatchers("Warning", this->Handler->ReallyCustomWarningMatches); this->WriteScrapeMatchers("WarningSuppress", this->Handler->ReallyCustomWarningExceptions); + + // Give some testing configuration information to the launcher. + std::string fname = this->Handler->CTestLaunchDir; + fname += "/CTestLaunchConfig.cmake"; + cmGeneratedFileStream fout(fname.c_str()); + std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory"); + fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n"; } //---------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index e68f5243bb..1f99aaa4de 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -292,6 +292,7 @@ int cmCTestLaunch::Run() return this->ExitCode; } + this->LoadConfig(); this->WriteXML(); return this->ExitCode; @@ -414,8 +415,21 @@ void cmCTestLaunch::WriteXMLAction(std::ostream& fxml) // SourceFile if(!this->OptionSource.empty()) { + std::string source = this->OptionSource; + cmSystemTools::ConvertToUnixSlashes(source); + + // If file is in source tree use its relative location. + if(cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) && + cmSystemTools::FileIsFullPath(source.c_str()) && + cmSystemTools::IsSubDirectory(source.c_str(), + this->SourceDir.c_str())) + { + source = cmSystemTools::RelativePath(this->SourceDir.c_str(), + source.c_str()); + } + fxml << "\t\t\t" - << cmXMLSafe(this->OptionSource) + << cmXMLSafe(source) << "\n"; } @@ -678,3 +692,26 @@ int cmCTestLaunch::Main(int argc, const char* const argv[]) cmCTestLaunch self(argc, argv); return self.Run(); } + +//---------------------------------------------------------------------------- +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmake.h" +#include +void cmCTestLaunch::LoadConfig() +{ + cmake cm; + cmGlobalGenerator gg; + gg.SetCMakeInstance(&cm); + cmsys::auto_ptr lg(gg.CreateLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); + std::string fname = this->LogDir; + fname += "CTestLaunchConfig.cmake"; + if(cmSystemTools::FileExists(fname.c_str()) && + mf->ReadListFile(0, fname.c_str())) + { + this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); + cmSystemTools::ConvertToUnixSlashes(this->SourceDir); + } +} diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index 14668708d0..9e92452269 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -100,6 +100,10 @@ private: void WriteXMLResult(std::ostream& fxml); void WriteXMLLabels(std::ostream& fxml); void DumpFileToXML(std::ostream& fxml, std::string const& fname); + + // Configuration + void LoadConfig(); + std::string SourceDir; }; #endif -- cgit v1.2.1