From 29db283ba76605de7a19d504cfeeb25d9e75cf90 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Thu, 1 Aug 2024 23:31:09 +0200 Subject: CTest: remove cmCTestLogWrite helper --- Source/CTest/cmCTestBuildHandler.cxx | 5 +++-- Source/CTest/cmCTestSubmitHandler.cxx | 13 +++++++------ Source/cmCTest.cxx | 16 ++++++---------- Source/cmCTest.h | 23 ----------------------- 4 files changed, 16 insertions(+), 41 deletions(-) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 859798e..e962cc7 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -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) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 85c77be..b0f07e5 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -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"); } } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index e1aefd9..f42d7f6 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -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& 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& 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()); } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index ae2431c..85f75fd 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -549,29 +549,6 @@ private: std::unique_ptr 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; \ -- cgit v0.12