cmake/Source/CTest/cmCTestBuildHandler.h

157 lines
4.2 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. */
2021-09-14 00:13:48 +02:00
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-07-09 11:21:54 +02:00
2018-04-23 21:13:27 +02:00
#include <chrono>
2022-03-29 21:10:50 +02:00
#include <cstddef>
2015-08-17 11:37:30 +02:00
#include <deque>
2016-10-30 18:24:19 +01:00
#include <iosfwd>
#include <string>
#include <vector>
2015-08-17 11:37:30 +02:00
2020-02-01 23:06:01 +01:00
#include "cmsys/RegularExpression.hxx"
#include "cmCTestGenericHandler.h"
#include "cmDuration.h"
#include "cmProcessOutput.h"
class cmMakefile;
2020-02-01 23:06:01 +01:00
class cmStringReplaceHelper;
2015-08-17 11:37:30 +02:00
class cmXMLWriter;
/** \class cmCTestBuildHandler
* \brief A class that handles ctest -S invocations
*
*/
class cmCTestBuildHandler : public cmCTestGenericHandler
{
public:
2020-02-01 23:06:01 +01:00
using Superclass = cmCTestGenericHandler;
using Encoding = cmProcessOutput::Encoding;
/*
* The main entry point for this class
*/
2018-01-26 17:06:56 +01:00
int ProcessHandler() override;
cmCTestBuildHandler();
2018-01-26 17:06:56 +01:00
void PopulateCustomVectors(cmMakefile* mf) override;
/**
* Initialize handler
*/
2018-01-26 17:06:56 +01:00
void Initialize() override;
2016-07-09 11:21:54 +02:00
int GetTotalErrors() { return this->TotalErrors; }
int GetTotalWarnings() { return this->TotalWarnings; }
2010-03-17 14:00:29 +02:00
private:
2010-03-17 14:00:29 +02:00
std::string GetMakeCommand();
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
2019-11-11 23:01:05 +01:00
int RunMakeCommand(const std::string& command, int* retVal, const char* dir,
2017-04-14 19:02:05 +02:00
int timeout, std::ostream& ofs,
Encoding encoding = cmProcessOutput::Auto);
2016-07-09 11:21:54 +02:00
enum
{
b_REGULAR_LINE,
b_WARNING_LINE,
b_ERROR_LINE
};
class cmCTestCompileErrorWarningRex
2016-07-09 11:21:54 +02:00
{
public:
cmCTestCompileErrorWarningRex() {}
int FileIndex;
int LineIndex;
cmsys::RegularExpression RegularExpression;
2016-07-09 11:21:54 +02:00
};
struct cmCTestBuildErrorWarning
{
2016-07-09 11:21:54 +02:00
bool Error;
int LogLine;
std::string Text;
std::string SourceFile;
std::string SourceFileTail;
2016-07-09 11:21:54 +02:00
int LineNumber;
std::string PreContext;
std::string PostContext;
};
// generate the XML output
2015-08-17 11:37:30 +02:00
void GenerateXMLHeader(cmXMLWriter& xml);
void GenerateXMLLaunched(cmXMLWriter& xml);
void GenerateXMLLogScraped(cmXMLWriter& xml);
2018-04-23 21:13:27 +02:00
void GenerateXMLFooter(cmXMLWriter& xml, cmDuration elapsed_build_time);
2009-10-04 10:30:41 +03:00
bool IsLaunchedErrorFile(const char* fname);
bool IsLaunchedWarningFile(const char* fname);
2016-07-09 11:21:54 +02:00
std::string StartBuild;
std::string EndBuild;
2018-04-23 21:13:27 +02:00
std::chrono::system_clock::time_point StartBuildTime;
std::chrono::system_clock::time_point EndBuildTime;
2015-04-27 22:25:09 +02:00
std::vector<std::string> CustomErrorMatches;
std::vector<std::string> CustomErrorExceptions;
std::vector<std::string> CustomWarningMatches;
std::vector<std::string> CustomWarningExceptions;
2009-10-04 10:30:41 +03:00
std::vector<std::string> ReallyCustomWarningMatches;
std::vector<std::string> ReallyCustomWarningExceptions;
std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
std::vector<cmsys::RegularExpression> ErrorMatchRegex;
std::vector<cmsys::RegularExpression> ErrorExceptionRegex;
std::vector<cmsys::RegularExpression> WarningMatchRegex;
std::vector<cmsys::RegularExpression> WarningExceptionRegex;
2020-02-01 23:06:01 +01:00
using t_BuildProcessingQueueType = std::deque<char>;
2017-04-14 19:02:05 +02:00
void ProcessBuffer(const char* data, size_t length, size_t& tick,
2016-07-09 11:21:54 +02:00
size_t tick_len, std::ostream& ofs,
t_BuildProcessingQueueType* queue);
int ProcessSingleLine(const char* data);
2016-07-09 11:21:54 +02:00
t_BuildProcessingQueueType BuildProcessingQueue;
t_BuildProcessingQueueType BuildProcessingErrorQueue;
size_t BuildOutputLogSize;
std::vector<char> CurrentProcessingLine;
2016-07-09 11:21:54 +02:00
std::string SimplifySourceDir;
std::string SimplifyBuildDir;
size_t OutputLineCounter;
2020-02-01 23:06:01 +01:00
using t_ErrorsAndWarningsVector = std::vector<cmCTestBuildErrorWarning>;
2016-07-09 11:21:54 +02:00
t_ErrorsAndWarningsVector ErrorsAndWarnings;
t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
size_t PostContextCount;
size_t MaxPreContext;
size_t MaxPostContext;
std::deque<std::string> PreContext;
int TotalErrors;
int TotalWarnings;
char LastTickChar;
bool ErrorQuotaReached;
bool WarningQuotaReached;
int MaxErrors;
int MaxWarnings;
2009-10-04 10:30:41 +03:00
2020-02-01 23:06:01 +01:00
// Used to remove ANSI color codes before checking for errors and warnings.
cmStringReplaceHelper* ColorRemover;
2009-10-04 10:30:41 +03:00
bool UseCTestLaunch;
std::string CTestLaunchDir;
class LaunchHelper;
2016-10-30 18:24:19 +01:00
2009-10-04 10:30:41 +03:00
friend class LaunchHelper;
class FragmentCompare;
};