diff options
author | Brad King <brad.king@kitware.com> | 2009-02-11 16:31:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-02-11 16:31:25 (GMT) |
commit | 0847d825b37aba91a1c118f5dec45c245639a61a (patch) | |
tree | 8996ab041f37325809fdf76e3051c9bb84df13da /Source/CTest/cmCTestLaunch.h | |
parent | 52692cccaabc51d5fd2c350264aadd4cdbbd0bfc (diff) | |
download | CMake-0847d825b37aba91a1c118f5dec45c245639a61a.zip CMake-0847d825b37aba91a1c118f5dec45c245639a61a.tar.gz CMake-0847d825b37aba91a1c118f5dec45c245639a61a.tar.bz2 |
ENH: Create internal 'ctest --launch' tool
This creates an undocumented 'ctest --launch' mode. It launches a
specified command and optionally records a failure in an xml fragment.
We will optionally use this in CTest's Build stage to record per-rule
build failure information when using Makefile generators.
Diffstat (limited to 'Source/CTest/cmCTestLaunch.h')
-rw-r--r-- | Source/CTest/cmCTestLaunch.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h new file mode 100644 index 0000000..1466870 --- /dev/null +++ b/Source/CTest/cmCTestLaunch.h @@ -0,0 +1,105 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmCTestLaunch_h +#define cmCTestLaunch_h + +#include "cmStandardIncludes.h" +#include <cmsys/RegularExpression.hxx> + +/** \class cmCTestLaunch + * \brief Launcher for make rules to report results for ctest + * + * This implements the 'ctest --launch' tool. + */ +class cmCTestLaunch +{ +public: + /** Entry point from ctest executable main(). */ + static int Main(int argc, const char* const* argv); +private: + // Initialize the launcher from its command line. + cmCTestLaunch(int argc, const char* const* argv); + ~cmCTestLaunch(); + + // Run the real command. + int Run(); + void RunChild(); + + // Methods to check the result of the real command. + bool IsError() const; + bool CheckResults(); + + // Launcher options specified before the real command. + std::string OptionOutput; + std::string OptionSource; + std::string OptionLanguage; + std::string OptionTargetName; + std::string OptionTargetType; + std::string OptionBuildDir; + bool ParseArguments(int argc, const char* const* argv); + + // The real command line appearing after launcher arguments. + int RealArgC; + const char* const* RealArgV; + std::string CWD; + + // The real command line after response file expansion. + std::vector<std::string> RealArgs; + void HandleRealArg(const char* arg); + + // A hash of the real command line is unique and unlikely to collide. + std::string LogHash; + void ComputeFileNames(); + + bool Passthru; + struct cmsysProcess_s* Process; + int ExitCode; + + // Temporary log files for stdout and stderr of real command. + std::string LogDir; + std::string LogOut; + std::string LogErr; + bool HaveOut; + bool HaveErr; + + // Labels associated with the build rule. + std::set<cmStdString> Labels; + void LoadLabels(); + bool SourceMatches(std::string const& lhs, + std::string const& rhs); + + // Regular expressions to match warnings and their exceptions. + bool ScrapeRulesLoaded; + std::vector<cmsys::RegularExpression> RegexWarning; + std::vector<cmsys::RegularExpression> RegexWarningSuppress; + void LoadScrapeRules(); + void LoadScrapeRules(const char* purpose, + std::vector<cmsys::RegularExpression>& regexps); + bool ScrapeLog(std::string const& fname); + bool Match(std::string const& line, + std::vector<cmsys::RegularExpression>& regexps); + + // Methods to generate the xml fragment. + void WriteXML(); + void WriteXMLAction(std::ostream& fxml); + void WriteXMLCommand(std::ostream& fxml); + void WriteXMLResult(std::ostream& fxml); + void WriteXMLLabels(std::ostream& fxml); + void DumpFileToXML(std::ostream& fxml, std::string const& fname); +}; + +#endif |