Commit 46769f82 by Jonah Ryan-Davis Committed by Commit Bot

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>
parent ff0c9ed6
......@@ -39,7 +39,7 @@ class InfoLog : angle::NonCopyable
~StreamHelper()
{
// Write newline when destroyed on the stack
if (mStream)
if (mStream && !mStream->str().empty())
{
(*mStream) << std::endl;
}
......
......@@ -858,7 +858,10 @@ void InfoLog::appendSanitized(const char *message)
}
} while (found != std::string::npos);
*mLazyStream << message << std::endl;
if (!msg.empty())
{
*mLazyStream << message << std::endl;
}
}
void InfoLog::reset()
......
......@@ -26,6 +26,17 @@ TEST(InfoLogTest, LogLengthCountsTerminator)
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.
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