Commit 0297dd80 by Jonah Ryan-Davis Committed by Kenneth Russell

[M90] Don't append newline to empty InfoLog stream.

Users were seeing different behavior when querying GL_INFO_LOG_LENGTH with ANGLE because ANGLE was always adding a newline to the InfoLog. Bug: chromium:1191293 Change-Id: I50f56326871cdd2f6614f5b1622257845721244c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2795164 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> (cherry picked from commit 46769f82) Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2807181 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
parent 1ba8c906
...@@ -39,7 +39,7 @@ class InfoLog : angle::NonCopyable ...@@ -39,7 +39,7 @@ class InfoLog : angle::NonCopyable
~StreamHelper() ~StreamHelper()
{ {
// Write newline when destroyed on the stack // Write newline when destroyed on the stack
if (mStream) if (mStream && !mStream->str().empty())
{ {
(*mStream) << std::endl; (*mStream) << std::endl;
} }
......
...@@ -858,7 +858,10 @@ void InfoLog::appendSanitized(const char *message) ...@@ -858,7 +858,10 @@ void InfoLog::appendSanitized(const char *message)
} }
} while (found != std::string::npos); } while (found != std::string::npos);
*mLazyStream << message << std::endl; if (!msg.empty())
{
*mLazyStream << message << std::endl;
}
} }
void InfoLog::reset() void InfoLog::reset()
......
...@@ -26,6 +26,17 @@ TEST(InfoLogTest, LogLengthCountsTerminator) ...@@ -26,6 +26,17 @@ TEST(InfoLogTest, LogLengthCountsTerminator)
EXPECT_EQ(3u, infoLog.getLength()); EXPECT_EQ(3u, infoLog.getLength());
} }
// Tests that the log doesn't append newlines to an empty string
TEST(InfoLogTest, InfoLogEmptyString)
{
InfoLog infoLog;
EXPECT_EQ(0u, infoLog.getLength());
infoLog << "";
// "" = 3 characters
EXPECT_EQ(0u, infoLog.getLength());
}
// Tests that newlines get appended to the info log properly. // Tests that newlines get appended to the info log properly.
TEST(InfoLogTest, AppendingNewline) TEST(InfoLogTest, AppendingNewline)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment