ProjectExplorer: Respect leading whitespace in custom output parsers

Leading spaces are often relevant and must not be trimmed.

Task-number: QTCREATORBUG-26892
Change-Id: Ie5c119a2c4df22f2c7bae2c9abaf5362d51c8c4e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-02-24 15:14:48 +01:00
parent 41038ba8cf
commit c5187da4ab

View File

@@ -271,7 +271,7 @@ OutputLineParser::Result CustomParser::parseLine(
CustomParserExpression::CustomParserChannel channel
)
{
const QString line = rawLine.trimmed();
const QString line = rightTrimmed(rawLine);
const Result res = hasMatch(line, channel, m_error, Task::Error);
if (res.status != Status::NotHandled)
return res;
@@ -629,6 +629,55 @@ void ProjectExplorerPlugin::testCustomOutputParsers_data()
<< QString() << QString()
<< Tasks({CompileTask(Task::Error, unitTestMessage, unitTestFileName, unitTestLineNumber)})
<< QString();
const QString leadingSpacesPattern = "^ MESSAGE:(.+)";
const QString leadingSpacesMessage = " MESSAGE:Error";
const QString noLeadingSpacesMessage = "MESSAGE:Error";
QTest::newRow("leading spaces: match")
<< leadingSpacesMessage
<< QString()
<< OutputParserTester::STDOUT
<< CustomParserExpression::ParseBothChannels
<< CustomParserExpression::ParseBothChannels
<< leadingSpacesPattern << 2 << 3 << 1
<< QString() << 1 << 2 << 3
<< QString() << QString()
<< Tasks({CompileTask(Task::Error, "Error", {}, -1)})
<< QString();
QTest::newRow("leading spaces: no match")
<< noLeadingSpacesMessage
<< QString()
<< OutputParserTester::STDOUT
<< CustomParserExpression::ParseBothChannels
<< CustomParserExpression::ParseBothChannels
<< leadingSpacesPattern << 2 << 3 << 1
<< QString() << 1 << 2 << 3
<< (noLeadingSpacesMessage + '\n') << QString()
<< Tasks()
<< QString();
const QString noLeadingSpacesPattern = "^MESSAGE:(.+)";
QTest::newRow("no leading spaces: match")
<< noLeadingSpacesMessage
<< QString()
<< OutputParserTester::STDOUT
<< CustomParserExpression::ParseBothChannels
<< CustomParserExpression::ParseBothChannels
<< noLeadingSpacesPattern << 2 << 3 << 1
<< QString() << 1 << 2 << 3
<< QString() << QString()
<< Tasks({CompileTask(Task::Error, "Error", {}, -1)})
<< QString();
QTest::newRow("no leading spaces: no match")
<< leadingSpacesMessage
<< QString()
<< OutputParserTester::STDOUT
<< CustomParserExpression::ParseBothChannels
<< CustomParserExpression::ParseBothChannels
<< noLeadingSpacesPattern << 3 << 2 << 1
<< QString() << 1 << 2 << 3
<< (leadingSpacesMessage + '\n') << QString()
<< Tasks()
<< QString();
}
void ProjectExplorerPlugin::testCustomOutputParsers()