Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/CTest/cmCTestBuildHandler.h
4998 views
1
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2
file LICENSE.rst or https://cmake.org/licensing for details. */
3
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <chrono>
8
#include <cstddef>
9
#include <deque>
10
#include <iosfwd>
11
#include <string>
12
#include <vector>
13
14
#include "cmsys/RegularExpression.hxx"
15
16
#include "cmCTestGenericHandler.h"
17
#include "cmDuration.h"
18
#include "cmProcessOutput.h"
19
20
class cmStringReplaceHelper;
21
class cmXMLWriter;
22
class cmCTest;
23
24
/** \class cmCTestBuildHandler
25
* \brief A class that handles ctest -S invocations
26
*
27
*/
28
class cmCTestBuildHandler : public cmCTestGenericHandler
29
{
30
public:
31
using Superclass = cmCTestGenericHandler;
32
using Encoding = cmProcessOutput::Encoding;
33
34
/*
35
* The main entry point for this class
36
*/
37
int ProcessHandler() override;
38
39
cmCTestBuildHandler(cmCTest* ctest);
40
41
void PopulateCustomVectors(cmMakefile* mf) override;
42
43
int GetTotalErrors() const { return this->TotalErrors; }
44
int GetTotalWarnings() const { return this->TotalWarnings; }
45
46
private:
47
std::string GetMakeCommand();
48
49
//! Run command specialized for make and configure. Returns process status
50
// and retVal is return value or exception.
51
bool RunMakeCommand(std::string const& command, int* retVal, char const* dir,
52
int timeout, std::ostream& ofs,
53
Encoding encoding = cmProcessOutput::Auto);
54
55
enum
56
{
57
b_REGULAR_LINE,
58
b_WARNING_LINE,
59
b_ERROR_LINE
60
};
61
62
class cmCTestCompileErrorWarningRex
63
{
64
public:
65
cmCTestCompileErrorWarningRex() {}
66
int FileIndex;
67
int LineIndex;
68
cmsys::RegularExpression RegularExpression;
69
};
70
71
struct cmCTestBuildErrorWarning
72
{
73
bool Error;
74
int LogLine;
75
std::string Text;
76
std::string SourceFile;
77
std::string SourceFileTail;
78
int LineNumber;
79
std::string PreContext;
80
std::string PostContext;
81
};
82
83
// generate the XML output
84
void GenerateXMLHeader(cmXMLWriter& xml);
85
void GenerateXMLLaunched(cmXMLWriter& xml);
86
void GenerateXMLLogScraped(cmXMLWriter& xml);
87
void GenerateInstrumentationXML(cmXMLWriter& xml);
88
void GenerateXMLFooter(cmXMLWriter& xml, cmDuration elapsed_build_time);
89
bool IsLaunchedErrorFile(char const* fname);
90
bool IsLaunchedWarningFile(char const* fname);
91
92
std::string StartBuild;
93
std::string EndBuild;
94
std::chrono::system_clock::time_point StartBuildTime;
95
std::chrono::system_clock::time_point EndBuildTime;
96
97
std::vector<std::string> CustomErrorMatches;
98
std::vector<std::string> CustomErrorExceptions;
99
std::vector<std::string> CustomWarningMatches;
100
std::vector<std::string> CustomWarningExceptions;
101
std::vector<std::string> ReallyCustomWarningMatches;
102
std::vector<std::string> ReallyCustomWarningExceptions;
103
std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
104
105
std::vector<cmsys::RegularExpression> ErrorMatchRegex;
106
std::vector<cmsys::RegularExpression> ErrorExceptionRegex;
107
std::vector<cmsys::RegularExpression> WarningMatchRegex;
108
std::vector<cmsys::RegularExpression> WarningExceptionRegex;
109
110
using t_BuildProcessingQueueType = std::deque<char>;
111
112
void ProcessBuffer(char const* data, size_t length, size_t& tick,
113
size_t tick_len, std::ostream& ofs,
114
t_BuildProcessingQueueType* queue);
115
int ProcessSingleLine(char const* data);
116
117
t_BuildProcessingQueueType BuildProcessingQueue;
118
t_BuildProcessingQueueType BuildProcessingErrorQueue;
119
size_t BuildOutputLogSize = 0;
120
std::vector<char> CurrentProcessingLine;
121
122
std::string SimplifySourceDir;
123
std::string SimplifyBuildDir;
124
size_t OutputLineCounter = 0;
125
using t_ErrorsAndWarningsVector = std::vector<cmCTestBuildErrorWarning>;
126
t_ErrorsAndWarningsVector ErrorsAndWarnings;
127
t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
128
size_t PostContextCount = 0;
129
size_t MaxPreContext = 10;
130
size_t MaxPostContext = 10;
131
std::deque<std::string> PreContext;
132
133
int TotalErrors = 0;
134
int TotalWarnings = 0;
135
char LastTickChar = '\0';
136
137
bool ErrorQuotaReached = false;
138
bool WarningQuotaReached = false;
139
140
int MaxErrors = 50;
141
int MaxWarnings = 50;
142
143
// Used to remove ANSI color codes before checking for errors and warnings.
144
cmStringReplaceHelper* ColorRemover;
145
146
bool UseCTestLaunch = false;
147
std::string CTestLaunchDir;
148
std::string LogFileName;
149
class LaunchHelper;
150
151
friend class LaunchHelper;
152
class FragmentCompare;
153
};
154
155