Commit d46ed701 authored by Morten Volden's avatar Morten Volden Committed by Kevin Funk

Make the filteringstrategy test work on Windows as well.

Summary: This requires some changes to some of the regexes used in CompilerFilterStrategy to get to work. Also the test itself is now somewhat more specific about what path type to test on which platform.

Test Plan: Compile the changes on Windows and verify that the test now passes (In Debug mode). Compile the changes on Linux and verify that all tests pass (as before). Verify that the bench number still look reasonable

Reviewers: #kdevelop, kfunk

Reviewed By: #kdevelop, kfunk

Subscribers: kdevelop-devel

Tags: #kdevelop

Differential Revision: https://phabricator.kde.org/D17098

(cherry picked from commit 35026c08)
parent 436303a9
...@@ -259,21 +259,21 @@ FilteredItem CompilerFilterStrategy::errorInLine(const QString& line) ...@@ -259,21 +259,21 @@ FilteredItem CompilerFilterStrategy::errorInLine(const QString& line)
ErrorFormat( QStringLiteral("^([a-zA-Z]:\\\\.+)\\(([1-9][0-9]*)\\): ((?:error|warning) .+\\:).*$"), 1, 2, 3 ), ErrorFormat( QStringLiteral("^([a-zA-Z]:\\\\.+)\\(([1-9][0-9]*)\\): ((?:error|warning) .+\\:).*$"), 1, 2, 3 ),
#endif #endif
// GCC - another case, eg. for #include "pixmap.xpm" which does not exists // GCC - another case, eg. for #include "pixmap.xpm" which does not exists
ErrorFormat( QStringLiteral("^([^:\\t]+):([0-9]+):([0-9]+):([^0-9]+)"), 1, 2, 4, 3 ), ErrorFormat( QStringLiteral("^(.:?[^:\\t]+):([0-9]+):([0-9]+):([^0-9]+)"), 1, 2, 4, 3 ),
// ant // ant
ErrorFormat( QStringLiteral("\\[javac\\][\\s]+([^:\\t]+):([0-9]+): (warning: .*|error: .*)"), 1, 2, 3, QStringLiteral("javac")), ErrorFormat( QStringLiteral("\\[javac\\][\\s]+([^:\\t]+):([0-9]+): (warning: .*|error: .*)"), 1, 2, 3, QStringLiteral("javac")),
// GCC // GCC
ErrorFormat( QStringLiteral("^([^:\\t]+):([0-9]+):([^0-9]+)"), 1, 2, 3 ), ErrorFormat( QStringLiteral("^(.:?[^:\\t]+):([0-9]+):([^0-9]+)"), 1, 2, 3 ),
// GCC // GCC
ErrorFormat( QStringLiteral("^(In file included from |[ ]+from )([^:\\t]+):([0-9]+)(:|,)(|[0-9]+)"), 2, 3, 5 ), ErrorFormat( QStringLiteral("^(In file included from |[ ]+from )(..[^:\\t]+):([0-9]+)(:|,)(|[0-9]+)"), 2, 3, 5 ),
// ICC // ICC
ErrorFormat( QStringLiteral("^([^:\\t]+)\\(([0-9]+)\\):([^0-9]+)"), 1, 2, 3, QStringLiteral("intel") ), ErrorFormat( QStringLiteral("^(.:?[^:\\t]+)\\(([0-9]+)\\):([^0-9]+)"), 1, 2, 3, QStringLiteral("intel") ),
//libtool link //libtool link
ErrorFormat( QStringLiteral("^(libtool):( link):( warning): "), 0, 0, 0 ), ErrorFormat( QStringLiteral("^(libtool):( link):( warning): "), 0, 0, 0 ),
// make // make
ErrorFormat( QStringLiteral("No rule to make target"), 0, 0, 0 ), ErrorFormat( QStringLiteral("No rule to make target"), 0, 0, 0 ),
// cmake - multiline expression // cmake - multiline expression
ErrorFormat( QStringLiteral("(^\\/[\\w|\\/| |\\.]+):([0-9]+):"), 1, 2, 0, QStringLiteral("cmake") ), ErrorFormat( QStringLiteral("((^\\/|^[a-zA-Z]:)[\\w|\\/| |\\.]+):([0-9]+):"), 1, 2, 0, QStringLiteral("cmake") ),
// cmake // cmake
ErrorFormat( QStringLiteral("CMake (Error|Warning) (|\\([a-zA-Z]+\\) )(in|at) ([^:]+):($|[0-9]+)"), 4, 5, 1, QStringLiteral("cmake") ), ErrorFormat( QStringLiteral("CMake (Error|Warning) (|\\([a-zA-Z]+\\) )(in|at) ([^:]+):($|[0-9]+)"), 4, 5, 1, QStringLiteral("cmake") ),
// cmake/automoc // cmake/automoc
...@@ -282,7 +282,7 @@ FilteredItem CompilerFilterStrategy::errorInLine(const QString& line) ...@@ -282,7 +282,7 @@ FilteredItem CompilerFilterStrategy::errorInLine(const QString& line)
// note: ':' after file name isn't always appended, see http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=317d8498aa02c9f486bf5071963bb2034777cdd6 // note: ':' after file name isn't always appended, see http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=317d8498aa02c9f486bf5071963bb2034777cdd6
// example: AUTOGEN: error: /foo/bar.cpp: The file includes (...) // example: AUTOGEN: error: /foo/bar.cpp: The file includes (...)
// note: AUTOMOC got renamed to AUTOGEN at some point // note: AUTOMOC got renamed to AUTOGEN at some point
ErrorFormat( QStringLiteral("^(AUTOMOC|AUTOGEN): error: ([^:]+):? (The file .*)$"), 2, 0, 0 ), ErrorFormat( QStringLiteral("^(AUTOMOC|AUTOGEN): error: (.*?) (The file .*)$"), 2, 0, 0 ),
// via qt4_automoc // via qt4_automoc
// example: automoc4: The file "/foo/bar.cpp" includes the moc file "bar1.moc", but ... // example: automoc4: The file "/foo/bar.cpp" includes the moc file "bar1.moc", but ...
ErrorFormat( QStringLiteral("^automoc4: The file \"([^\"]+)\" includes the moc file"), 1, 0, 0 ), ErrorFormat( QStringLiteral("^automoc4: The file \"([^\"]+)\" includes the moc file"), 1, 0, 0 ),
......
...@@ -74,24 +74,29 @@ void TestFilteringStrategy::testNoFilterStrategy_data() ...@@ -74,24 +74,29 @@ void TestFilteringStrategy::testNoFilterStrategy_data()
QTest::addColumn<QString>("line"); QTest::addColumn<QString>("line");
QTest::addColumn<FilteredItem::FilteredOutputItemType>("expected"); QTest::addColumn<FilteredItem::FilteredOutputItemType>("expected");
QTest::newRow("cppcheck-info-line") for (TestPathType pathType :
<< buildCppCheckInformationLine() << FilteredItem::InvalidItem; #ifdef Q_OS_WIN
for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { {WindowsFilePathNoSpaces, WindowsFilePathWithSpaces}
#else
{UnixFilePathNoSpaces, UnixFilePathWithSpaces}
#endif
) {
QTest::newRowForPathType("cppcheck-error-line", pathType) QTest::newRowForPathType("cppcheck-error-line", pathType)
<< buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem; << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem;
QTest::newRowForPathType("compiler-line", pathType) QTest::newRowForPathType("compiler-line", pathType)
<< buildCompilerLine(pathType) << FilteredItem::InvalidItem; << buildCompilerLine(pathType) << FilteredItem::InvalidItem;
QTest::newRowForPathType("compiler-error-line", pathType) QTest::newRowForPathType("compiler-error-line", pathType)
<< buildCompilerErrorLine(pathType) << FilteredItem::InvalidItem; << buildCompilerErrorLine(pathType) << FilteredItem::InvalidItem;
}
QTest::newRow("compiler-action-line")
<< buildCompilerActionLine() << FilteredItem::InvalidItem;
for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) {
QTest::newRowForPathType("compiler-information-line", pathType) QTest::newRowForPathType("compiler-information-line", pathType)
<< buildCompilerInformationLine(pathType) << FilteredItem::InvalidItem; << buildCompilerInformationLine(pathType) << FilteredItem::InvalidItem;
QTest::newRowForPathType("python-error-line", pathType) QTest::newRowForPathType("python-error-line", pathType)
<< buildPythonErrorLine(pathType) << FilteredItem::InvalidItem; << buildPythonErrorLine(pathType) << FilteredItem::InvalidItem;
} }
QTest::newRow("cppcheck-info-line")
<< buildCppCheckInformationLine() << FilteredItem::InvalidItem;
QTest::newRow("compiler-action-line")
<< buildCompilerActionLine() << FilteredItem::InvalidItem;
} }
void TestFilteringStrategy::testNoFilterStrategy() void TestFilteringStrategy::testNoFilterStrategy()
...@@ -114,7 +119,13 @@ void TestFilteringStrategy::testCompilerFilterStrategy_data() ...@@ -114,7 +119,13 @@ void TestFilteringStrategy::testCompilerFilterStrategy_data()
QTest::newRow("cppcheck-info-line") QTest::newRow("cppcheck-info-line")
<< buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces;
for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) { for (TestPathType pathType :
#ifdef Q_OS_WIN
{WindowsFilePathNoSpaces, WindowsFilePathWithSpaces}
#else
{UnixFilePathNoSpaces, UnixFilePathWithSpaces}
#endif
) {
QTest::newRowForPathType("cppcheck-error-line", pathType) QTest::newRowForPathType("cppcheck-error-line", pathType)
<< buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType; << buildCppCheckErrorLine(pathType) << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType;
QTest::newRowForPathType("compiler-line", pathType) QTest::newRowForPathType("compiler-line", pathType)
...@@ -127,26 +138,22 @@ void TestFilteringStrategy::testCompilerFilterStrategy_data() ...@@ -127,26 +138,22 @@ void TestFilteringStrategy::testCompilerFilterStrategy_data()
<< buildInfileIncludedFromFirstLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; << buildInfileIncludedFromFirstLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType;
QTest::newRowForPathType("compiler-information-line3", pathType) QTest::newRowForPathType("compiler-information-line3", pathType)
<< buildInfileIncludedFromSecondLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType; << buildInfileIncludedFromSecondLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType;
} QTest::newRow("cmake-error-line1")
QTest::newRow("cmake-error-line1") << "CMake Error at CMakeLists.txt:2 (cmake_minimum_required):" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType;
<< "CMake Error at CMakeLists.txt:2 (cmake_minimum_required):" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; QTest::newRow("cmake-error-multiline1")
QTest::newRow("cmake-error-multiline1") << "CMake Error: Error in cmake code at" << FilteredItem::InvalidItem << FilteredItem::InvalidItem << pathType;
<< "CMake Error: Error in cmake code at" << FilteredItem::InvalidItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces;
for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) {
QTest::newRowForPathType("cmake-error-multiline2", pathType) QTest::newRowForPathType("cmake-error-multiline2", pathType)
<< buildCmakeConfigureMultiLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; << buildCmakeConfigureMultiLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType;
} QTest::newRowForPathType("cmake-warning-line", pathType)
QTest::newRow("cmake-warning-line") << "CMake Warning (dev) in CMakeLists.txt:" << FilteredItem::WarningItem << FilteredItem::InvalidItem << pathType;
<< "CMake Warning (dev) in CMakeLists.txt:" << FilteredItem::WarningItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; QTest::newRowForPathType("cmake-automoc-error", pathType)
QTest::newRow("cmake-automoc-error") << buildAutoMocLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType;
<< "AUTOMOC: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; QTest::newRowForPathType("cmake-automoc4-error", pathType)
QTest::newRow("cmake-automoc4-error") << buildOldAutoMocLine(pathType) << FilteredItem::InformationItem << FilteredItem::InvalidItem << pathType;
<< "automoc4: The file \"/foo/bar.cpp\" includes the moc file \"bar1.moc\"" << FilteredItem::InformationItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; QTest::newRowForPathType("cmake-autogen-error", pathType)
QTest::newRow("cmake-autogen-error") << buildAutoMocLine(pathType, false) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType;
<< "AUTOGEN: error: /foo/bar.cpp The file includes the moc file \"moc_bar1.cpp\"" << FilteredItem::ErrorItem << FilteredItem::InvalidItem << UnixFilePathNoSpaces; QTest::newRowForPathType("linker-action-line", pathType)
QTest::newRow("linker-action-line") << "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::ActionItem << pathType;
<< "linking testCustombuild (g++)" << FilteredItem::InvalidItem << FilteredItem::ActionItem << UnixFilePathNoSpaces;
for (TestPathType pathType : {UnixFilePathNoSpaces, UnixFilePathWithSpaces}) {
QTest::newRowForPathType("linker-error-line", pathType) QTest::newRowForPathType("linker-error-line", pathType)
<< buildLinkerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType; << buildLinkerErrorLine(pathType) << FilteredItem::ErrorItem << FilteredItem::InvalidItem << pathType;
QTest::newRowForPathType("python-error-line", pathType) QTest::newRowForPathType("python-error-line", pathType)
...@@ -191,10 +198,15 @@ void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords_data() ...@@ -191,10 +198,15 @@ void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords_data()
void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords() void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords()
{ {
#ifdef Q_OS_WIN
TestPathType pathTypeToUse = WindowsFilePathNoSpaces;
#else
TestPathType pathTypeToUse = UnixFilePathNoSpaces;
#endif
QFETCH(QString, line); QFETCH(QString, line);
QFETCH(FilteredItem::FilteredOutputItemType, expectedError); QFETCH(FilteredItem::FilteredOutputItemType, expectedError);
QFETCH(FilteredItem::FilteredOutputItemType, expectedAction); QFETCH(FilteredItem::FilteredOutputItemType, expectedAction);
QUrl projecturl = QUrl::fromLocalFile( projectPath() ); QUrl projecturl = QUrl::fromLocalFile( projectPath(pathTypeToUse) );
CompilerFilterStrategy testee(projecturl); CompilerFilterStrategy testee(projecturl);
FilteredItem item1 = testee.errorInLine(line); FilteredItem item1 = testee.errorInLine(line);
QCOMPARE(item1.type, expectedError); QCOMPARE(item1.type, expectedError);
......
...@@ -153,6 +153,23 @@ QString buildCmakeConfigureMultiLine(TestPathType pathType = UnixFilePathNoSpace ...@@ -153,6 +153,23 @@ QString buildCmakeConfigureMultiLine(TestPathType pathType = UnixFilePathNoSpace
return outputline; return outputline;
} }
QString buildAutoMocLine(TestPathType pathType = UnixFilePathNoSpaces, bool useAutoMoc = true)
{
QString outputline;
useAutoMoc ? outputline.append("AUTOMOC: error: ") : outputline.append("AUTOGEN: error: ");
outputline.append(projectPath(pathType));
outputline.append("bar.cpp The file includes the moc file \"moc_bar1.cpp\"");
return outputline;
}
QString buildOldAutoMocLine(TestPathType pathType = UnixFilePathNoSpaces)
{
QString outputline;
outputline.append("automoc4: The file \"");
outputline.append(projectPath(pathType));
outputline.append("bar.cpp\" includes the moc file \"bar1.moc\"");
return outputline;
}
QString buildLinkerErrorLine(TestPathType pathType = UnixFilePathNoSpaces) QString buildLinkerErrorLine(TestPathType pathType = UnixFilePathNoSpaces)
{ {
......
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