CTest: remove cmCTestLogWrite helper

This commit is contained in:
Daniel Pfeifer
2024-08-01 23:31:09 +02:00
parent 98d86fdc62
commit 29db283ba7
4 changed files with 16 additions and 41 deletions

View File

@@ -8,6 +8,7 @@
#include <set>
#include <utility>
#include <cm/string_view>
#include <cmext/algorithm>
#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
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
cmCTestLogWrite(data, length));
cm::string_view(data, length));
// Always store the chunk to the file
ofs << cmCTestLogWrite(data, length);
ofs << cm::string_view(data, length);
}
int cmCTestBuildHandler::ProcessSingleLine(const char* data)

View File

@@ -9,6 +9,7 @@
#include <cm/iomanip>
#include <cm/optional>
#include <cm/string_view>
#include <cmext/algorithm>
#include <cm3p/curl/curl.h>
@@ -360,7 +361,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
if (!chunk.empty()) {
cmCTestOptionalLog(this->CTest, DEBUG,
"CURL output: ["
<< cmCTestLogWrite(chunk.data(), chunk.size())
<< cm::string_view(chunk.data(), chunk.size())
<< "]" << std::endl,
this->Quiet);
this->ParseResponse(chunk);
@@ -369,7 +370,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
cmCTestOptionalLog(
this->CTest, DEBUG,
"CURL debug output: ["
<< cmCTestLogWrite(chunkDebug.data(), chunkDebug.size()) << "]"
<< cm::string_view(chunkDebug.data(), chunkDebug.size()) << "]"
<< std::endl,
this->Quiet);
}
@@ -423,7 +424,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
if (!chunk.empty()) {
cmCTestOptionalLog(this->CTest, DEBUG,
"CURL output: ["
<< cmCTestLogWrite(chunk.data(), chunk.size())
<< cm::string_view(chunk.data(), chunk.size())
<< "]" << std::endl,
this->Quiet);
this->ParseResponse(chunk);
@@ -451,11 +452,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
// avoid deref of begin for zero size array
if (!chunk.empty()) {
*this->LogFile << " Curl output was: "
<< cmCTestLogWrite(chunk.data(), chunk.size())
<< cm::string_view(chunk.data(), chunk.size())
<< std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE,
"CURL output: ["
<< cmCTestLogWrite(chunk.data(), chunk.size()) << "]"
<< cm::string_view(chunk.data(), chunk.size()) << "]"
<< std::endl);
}
::curl_easy_cleanup(curl);
@@ -504,7 +505,7 @@ void cmCTestSubmitHandler::ParseResponse(
if (this->HasWarnings || this->HasErrors) {
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Server Response:\n"
<< cmCTestLogWrite(chunk.data(), chunk.size()) << "\n");
<< cm::string_view(chunk.data(), chunk.size()) << "\n");
}
}

View File

@@ -1140,10 +1140,9 @@ bool cmCTest::RunMakeCommand(const std::string& command, std::string& output,
<< "K\n " << std::flush);
}
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
cmCTestLogWrite(strdata.c_str(), strdata.size()));
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
if (ofs) {
ofs << cmCTestLogWrite(strdata.c_str(), strdata.size());
ofs << strdata;
}
},
[this, &processOutput, &output, &ofs]() {
@@ -1151,10 +1150,9 @@ bool cmCTest::RunMakeCommand(const std::string& command, std::string& output,
processOutput.DecodeText(std::string(), strdata);
if (!strdata.empty()) {
output.append(strdata);
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
cmCTestLogWrite(strdata.c_str(), strdata.size()));
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
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) {
cm::append(tempOutput, data.data(), data.data() + data.size());
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
cmCTestLogWrite(strdata.c_str(), strdata.size()));
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
if (log) {
log->write(strdata.c_str(), strdata.size());
}
@@ -1316,8 +1313,7 @@ bool cmCTest::RunTest(const std::vector<std::string>& argv,
std::string strdata;
processOutput.DecodeText(std::string(), strdata);
if (!strdata.empty()) {
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
cmCTestLogWrite(strdata.c_str(), strdata.size()));
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, strdata);
if (log) {
log->write(strdata.c_str(), strdata.size());
}

View File

@@ -549,29 +549,6 @@ private:
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) \
do { \
std::ostringstream cmCTestLog_msg; \