mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
CTest: remove cmCTestLogWrite helper
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <cm/string_view>
|
||||||
#include <cmext/algorithm>
|
#include <cmext/algorithm>
|
||||||
|
|
||||||
#include <cm3p/uv.h>
|
#include <cm3p/uv.h>
|
||||||
@@ -1121,10 +1122,10 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
|
|||||||
|
|
||||||
// And if this is verbose output, display the content of the chunk
|
// And if this is verbose output, display the content of the chunk
|
||||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
cmCTestLogWrite(data, length));
|
cm::string_view(data, length));
|
||||||
|
|
||||||
// Always store the chunk to the file
|
// Always store the chunk to the file
|
||||||
ofs << cmCTestLogWrite(data, length);
|
ofs << cm::string_view(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmCTestBuildHandler::ProcessSingleLine(const char* data)
|
int cmCTestBuildHandler::ProcessSingleLine(const char* data)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <cm/iomanip>
|
#include <cm/iomanip>
|
||||||
#include <cm/optional>
|
#include <cm/optional>
|
||||||
|
#include <cm/string_view>
|
||||||
#include <cmext/algorithm>
|
#include <cmext/algorithm>
|
||||||
|
|
||||||
#include <cm3p/curl/curl.h>
|
#include <cm3p/curl/curl.h>
|
||||||
@@ -360,7 +361,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
|
|||||||
if (!chunk.empty()) {
|
if (!chunk.empty()) {
|
||||||
cmCTestOptionalLog(this->CTest, DEBUG,
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
||||||
"CURL output: ["
|
"CURL output: ["
|
||||||
<< cmCTestLogWrite(chunk.data(), chunk.size())
|
<< cm::string_view(chunk.data(), chunk.size())
|
||||||
<< "]" << std::endl,
|
<< "]" << std::endl,
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
this->ParseResponse(chunk);
|
this->ParseResponse(chunk);
|
||||||
@@ -369,7 +370,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
|
|||||||
cmCTestOptionalLog(
|
cmCTestOptionalLog(
|
||||||
this->CTest, DEBUG,
|
this->CTest, DEBUG,
|
||||||
"CURL debug output: ["
|
"CURL debug output: ["
|
||||||
<< cmCTestLogWrite(chunkDebug.data(), chunkDebug.size()) << "]"
|
<< cm::string_view(chunkDebug.data(), chunkDebug.size()) << "]"
|
||||||
<< std::endl,
|
<< std::endl,
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
}
|
}
|
||||||
@@ -423,7 +424,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
|
|||||||
if (!chunk.empty()) {
|
if (!chunk.empty()) {
|
||||||
cmCTestOptionalLog(this->CTest, DEBUG,
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
||||||
"CURL output: ["
|
"CURL output: ["
|
||||||
<< cmCTestLogWrite(chunk.data(), chunk.size())
|
<< cm::string_view(chunk.data(), chunk.size())
|
||||||
<< "]" << std::endl,
|
<< "]" << std::endl,
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
this->ParseResponse(chunk);
|
this->ParseResponse(chunk);
|
||||||
@@ -451,11 +452,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
|
|||||||
// avoid deref of begin for zero size array
|
// avoid deref of begin for zero size array
|
||||||
if (!chunk.empty()) {
|
if (!chunk.empty()) {
|
||||||
*this->LogFile << " Curl output was: "
|
*this->LogFile << " Curl output was: "
|
||||||
<< cmCTestLogWrite(chunk.data(), chunk.size())
|
<< cm::string_view(chunk.data(), chunk.size())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
"CURL output: ["
|
"CURL output: ["
|
||||||
<< cmCTestLogWrite(chunk.data(), chunk.size()) << "]"
|
<< cm::string_view(chunk.data(), chunk.size()) << "]"
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
}
|
}
|
||||||
::curl_easy_cleanup(curl);
|
::curl_easy_cleanup(curl);
|
||||||
@@ -504,7 +505,7 @@ void cmCTestSubmitHandler::ParseResponse(
|
|||||||
if (this->HasWarnings || this->HasErrors) {
|
if (this->HasWarnings || this->HasErrors) {
|
||||||
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
||||||
" Server Response:\n"
|
" Server Response:\n"
|
||||||
<< cmCTestLogWrite(chunk.data(), chunk.size()) << "\n");
|
<< cm::string_view(chunk.data(), chunk.size()) << "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1140,10 +1140,9 @@ bool cmCTest::RunMakeCommand(const std::string& command, std::string& output,
|
|||||||
<< "K\n " << std::flush);
|
<< "K\n " << std::flush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
|
||||||
cmCTestLogWrite(strdata.c_str(), strdata.size()));
|
|
||||||
if (ofs) {
|
if (ofs) {
|
||||||
ofs << cmCTestLogWrite(strdata.c_str(), strdata.size());
|
ofs << strdata;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[this, &processOutput, &output, &ofs]() {
|
[this, &processOutput, &output, &ofs]() {
|
||||||
@@ -1151,10 +1150,9 @@ bool cmCTest::RunMakeCommand(const std::string& command, std::string& output,
|
|||||||
processOutput.DecodeText(std::string(), strdata);
|
processOutput.DecodeText(std::string(), strdata);
|
||||||
if (!strdata.empty()) {
|
if (!strdata.empty()) {
|
||||||
output.append(strdata);
|
output.append(strdata);
|
||||||
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
|
||||||
cmCTestLogWrite(strdata.c_str(), strdata.size()));
|
|
||||||
if (ofs) {
|
if (ofs) {
|
||||||
ofs << cmCTestLogWrite(strdata.c_str(), strdata.size());
|
ofs << strdata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1306,8 +1304,7 @@ bool cmCTest::RunTest(const std::vector<std::string>& argv,
|
|||||||
if (output) {
|
if (output) {
|
||||||
cm::append(tempOutput, data.data(), data.data() + data.size());
|
cm::append(tempOutput, data.data(), data.data() + data.size());
|
||||||
}
|
}
|
||||||
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
|
||||||
cmCTestLogWrite(strdata.c_str(), strdata.size()));
|
|
||||||
if (log) {
|
if (log) {
|
||||||
log->write(strdata.c_str(), strdata.size());
|
log->write(strdata.c_str(), strdata.size());
|
||||||
}
|
}
|
||||||
@@ -1316,8 +1313,7 @@ bool cmCTest::RunTest(const std::vector<std::string>& argv,
|
|||||||
std::string strdata;
|
std::string strdata;
|
||||||
processOutput.DecodeText(std::string(), strdata);
|
processOutput.DecodeText(std::string(), strdata);
|
||||||
if (!strdata.empty()) {
|
if (!strdata.empty()) {
|
||||||
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
|
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
|
||||||
cmCTestLogWrite(strdata.c_str(), strdata.size()));
|
|
||||||
if (log) {
|
if (log) {
|
||||||
log->write(strdata.c_str(), strdata.size());
|
log->write(strdata.c_str(), strdata.size());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -549,29 +549,6 @@ private:
|
|||||||
std::unique_ptr<Private> Impl;
|
std::unique_ptr<Private> Impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cmCTestLogWrite
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cmCTestLogWrite(const char* data, size_t length)
|
|
||||||
: Data(data)
|
|
||||||
, Length(length)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Data;
|
|
||||||
size_t Length;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& os, const cmCTestLogWrite& c)
|
|
||||||
{
|
|
||||||
if (!c.Length) {
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
os.write(c.Data, c.Length);
|
|
||||||
os.flush();
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define cmCTestLog(ctSelf, logType, msg) \
|
#define cmCTestLog(ctSelf, logType, msg) \
|
||||||
do { \
|
do { \
|
||||||
std::ostringstream cmCTestLog_msg; \
|
std::ostringstream cmCTestLog_msg; \
|
||||||
|
|||||||
Reference in New Issue
Block a user