cmake/Source/CTest/cmCTestLaunch.h

108 lines
3.0 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2009-10-04 10:30:41 +03:00
#ifndef cmCTestLaunch_h
#define cmCTestLaunch_h
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-07-09 11:21:54 +02:00
2016-10-30 18:24:19 +01:00
#include <set>
#include <string>
#include <vector>
2009-10-04 10:30:41 +03:00
2020-02-01 23:06:01 +01:00
#include "cmsys/RegularExpression.hxx"
2018-08-09 18:06:22 +02:00
class cmXMLElement;
2015-08-17 11:37:30 +02:00
2009-10-04 10:30:41 +03:00
/** \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(). */
2012-02-18 12:40:36 +02:00
static int Main(int argc, const char* const argv[]);
2016-07-09 11:21:54 +02:00
2009-10-04 10:30:41 +03:00
private:
// Initialize the launcher from its command line.
cmCTestLaunch(int argc, const char* const* argv);
~cmCTestLaunch();
2019-11-11 23:01:05 +01:00
cmCTestLaunch(const cmCTestLaunch&) = delete;
cmCTestLaunch& operator=(const cmCTestLaunch&) = delete;
2009-10-04 10:30:41 +03:00
// 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;
2014-08-03 19:52:23 +02:00
std::string OptionFilterPrefix;
2009-10-04 10:30:41 +03:00
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.
2015-04-27 22:25:09 +02:00
std::set<std::string> Labels;
2009-10-04 10:30:41 +03:00
void LoadLabels();
2016-07-09 11:21:54 +02:00
bool SourceMatches(std::string const& lhs, std::string const& rhs);
2009-10-04 10:30:41 +03:00
// 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);
2014-08-03 19:52:23 +02:00
bool MatchesFilterPrefix(std::string const& line) const;
2009-10-04 10:30:41 +03:00
// Methods to generate the xml fragment.
void WriteXML();
2018-08-09 18:06:22 +02:00
void WriteXMLAction(cmXMLElement&);
void WriteXMLCommand(cmXMLElement&);
void WriteXMLResult(cmXMLElement&);
void WriteXMLLabels(cmXMLElement&);
void DumpFileToXML(cmXMLElement&, const char* tag, std::string const& fname);
2009-10-04 10:30:41 +03:00
// Configuration
void LoadConfig();
std::string SourceDir;
};
#endif