From 15bb1b0c4d402a9beaf2dcdd427d9dd9b33b29cd Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Wed, 18 May 2011 18:39:14 +0200 Subject: [PATCH] Parser: Make parser test engine more strict * Fix unit tests to work with this stricter version Change-Id: Iaf6d333e4b4df54ddc340d261ce28538bfa1f3cf --- src/plugins/projectexplorer/gccparser.cpp | 12 ++++++------ src/plugins/projectexplorer/gnumakeparser.cpp | 10 +++++----- src/plugins/projectexplorer/linuxiccparser.cpp | 10 +++++----- src/plugins/projectexplorer/msvcparser.cpp | 4 ++-- src/plugins/projectexplorer/outputparser_test.cpp | 12 +++++------- src/plugins/projectexplorer/projectexplorer.h | 3 +++ src/plugins/qt4projectmanager/qmakeparser.cpp | 4 ++-- src/plugins/qt4projectmanager/qt-s60/abldparser.cpp | 4 ++-- src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp | 4 ++-- src/plugins/qt4projectmanager/qtparser.cpp | 6 +++--- 10 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/plugins/projectexplorer/gccparser.cpp b/src/plugins/projectexplorer/gccparser.cpp index acc5f9f95a9..b276e07f26a 100644 --- a/src/plugins/projectexplorer/gccparser.cpp +++ b/src/plugins/projectexplorer/gccparser.cpp @@ -152,12 +152,12 @@ void ProjectExplorerPlugin::testGccOutputParsers_data() QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<ProjectExplorer::Task>() << QString(); @@ -337,7 +337,7 @@ void ProjectExplorerPlugin::testGccOutputParsers_data() "distcc[73168] (dcc_build_somewhere) Warning: failed to distribute, running locally instead") << OutputParserTester::STDERR << QString() << QString::fromLatin1("distcc[73168] (dcc_get_hostlist) Warning: no hostlist is set; can't distribute work\n" - "distcc[73168] (dcc_build_somewhere) Warning: failed to distribute, running locally instead") + "distcc[73168] (dcc_build_somewhere) Warning: failed to distribute, running locally instead\n") << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("ld warning (QTCREATORBUG-905)") @@ -363,7 +363,7 @@ void ProjectExplorerPlugin::testGccOutputParsers_data() QTest::newRow("Teambuilder issues") << QString::fromLatin1("TeamBuilder Client:: error: could not find Scheduler, running Job locally...") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("TeamBuilder Client:: error: could not find Scheduler, running Job locally...") + << QString() << QString::fromLatin1("TeamBuilder Client:: error: could not find Scheduler, running Job locally...\n") << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("note") @@ -394,13 +394,13 @@ void ProjectExplorerPlugin::testGccOutputParsers_data() QTest::newRow("rm false positive") << QString::fromLatin1("rm: cannot remove `release/moc_mainwindow.cpp': No such file or directory") << OutputParserTester::STDERR - << QString() << QString("rm: cannot remove `release/moc_mainwindow.cpp': No such file or directory") + << QString() << QString("rm: cannot remove `release/moc_mainwindow.cpp': No such file or directory\n") << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("ranlib false positive") << QString::fromLatin1("ranlib: file: libSupport.a(HashTable.o) has no symbols") << OutputParserTester::STDERR - << QString() << QString("ranlib: file: libSupport.a(HashTable.o) has no symbols") + << QString() << QString("ranlib: file: libSupport.a(HashTable.o) has no symbols\n") << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("ld: missing library") diff --git a/src/plugins/projectexplorer/gnumakeparser.cpp b/src/plugins/projectexplorer/gnumakeparser.cpp index a6b0ea5a8ab..bd8573f7131 100644 --- a/src/plugins/projectexplorer/gnumakeparser.cpp +++ b/src/plugins/projectexplorer/gnumakeparser.cpp @@ -204,14 +204,14 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing_data() QTest::newRow("pass-through stdout") << QStringList() << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<Task>() << QString() << QStringList(); QTest::newRow("pass-through stderr") << QStringList() << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<Task>() << QString() << QStringList(); @@ -221,7 +221,7 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing_data() "../../scriptbug/main.cpp: At global scope:\n" "../../scriptbug/main.cpp: In instantiation of void bar(i) [with i = double]:\n" "../../scriptbug/main.cpp:8: instantiated from void foo(i) [with i = double]\n" - "../../scriptbug/main.cpp:22: instantiated from here\n") + "../../scriptbug/main.cpp:22: instantiated from here") << OutputParserTester::STDERR << QString() << QString::fromLatin1("/temp/test/untitled8/main.cpp: In function `int main(int, char**)':\n" @@ -237,7 +237,7 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing_data() QTest::newRow("entering directory") << (QStringList() << QString::fromLatin1("/test/dir") ) << QString::fromLatin1("make[4]: Entering directory `/home/code/build/qt/examples/opengl/grabber'\n" - "make[4]: Entering directory `/home/code/build/qt/examples/opengl/grabber'\n") + "make[4]: Entering directory `/home/code/build/qt/examples/opengl/grabber'") << OutputParserTester::STDOUT << QString() << QString() << QList<Task>() @@ -320,7 +320,7 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing_data() << QStringList() << QString::fromLatin1("/home/dev/creator/share/qtcreator/gdbmacros/gdbmacros.cpp:1079: note: initialized from here") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("/home/dev/creator/share/qtcreator/gdbmacros/gdbmacros.cpp:1079: note: initialized from here") + << QString() << QString::fromLatin1("/home/dev/creator/share/qtcreator/gdbmacros/gdbmacros.cpp:1079: note: initialized from here\n") << QList<ProjectExplorer::Task>() << QString() << QStringList(); diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp index d362442b8f4..074eaf4352f 100644 --- a/src/plugins/projectexplorer/linuxiccparser.cpp +++ b/src/plugins/projectexplorer/linuxiccparser.cpp @@ -131,12 +131,12 @@ void ProjectExplorerPlugin::testLinuxIccOutputParsers_data() QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<ProjectExplorer::Task>() << QString(); @@ -146,7 +146,7 @@ void ProjectExplorerPlugin::testLinuxIccOutputParsers_data() " ^\n" "\n") << OutputParserTester::STDERR - << QString() << QString() + << QString() << QString::fromLatin1("\n") << (QList<ProjectExplorer::Task>() << Task(Task::Error, QLatin1String("identifier \"f\" is undefined\nf(0);"), @@ -160,7 +160,7 @@ void ProjectExplorerPlugin::testLinuxIccOutputParsers_data() " ^\n" "\n") << OutputParserTester::STDERR - << QString() << QString() + << QString() << QString::fromLatin1("\n") << (QList<ProjectExplorer::Task>() << Task(Task::Error, QLatin1String("function \"AClass::privatefunc\" (declared at line 4 of \"main.h\") is inaccessible\nb.privatefunc();"), @@ -174,7 +174,7 @@ void ProjectExplorerPlugin::testLinuxIccOutputParsers_data() " ^\n" "\n") << OutputParserTester::STDERR - << QString() << QString() + << QString() << QString::fromLatin1("\n") << (QList<ProjectExplorer::Task>() << Task(Task::Warning, QLatin1String("use of \"=\" where \"==\" may have been intended\nwhile (a = true)"), diff --git a/src/plugins/projectexplorer/msvcparser.cpp b/src/plugins/projectexplorer/msvcparser.cpp index 1b59a4893e9..66ef257a80d 100644 --- a/src/plugins/projectexplorer/msvcparser.cpp +++ b/src/plugins/projectexplorer/msvcparser.cpp @@ -163,12 +163,12 @@ void ProjectExplorerPlugin::testMsvcOutputParsers_data() QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<ProjectExplorer::Task>() << QString(); diff --git a/src/plugins/projectexplorer/outputparser_test.cpp b/src/plugins/projectexplorer/outputparser_test.cpp index a9311a3910e..a6b273ae66c 100644 --- a/src/plugins/projectexplorer/outputparser_test.cpp +++ b/src/plugins/projectexplorer/outputparser_test.cpp @@ -63,9 +63,9 @@ void OutputParserTester::testParsing(const QString &lines, QStringList inputLines = lines.split(QChar('\n')); foreach (const QString &input, inputLines) { if (inputChannel == STDOUT) - childParser()->stdOutput(input); + childParser()->stdOutput(input + QLatin1Char('\n')); else - childParser()->stdError(input); + childParser()->stdError(input + QLatin1Char('\n')); } // first disconnect ourselves from the end of the parser chain again IOutputParser * parser = this; @@ -91,7 +91,7 @@ void OutputParserTester::testParsing(const QString &lines, QCOMPARE(m_receivedTasks.at(i).description, tasks.at(i).description); QCOMPARE(m_receivedTasks.at(i).file, tasks.at(i).file); QCOMPARE(m_receivedTasks.at(i).line, tasks.at(i).line); - QCOMPARE(m_receivedTasks.at(i).type, tasks.at(i).type); + QCOMPARE(static_cast<int>(m_receivedTasks.at(i).type), static_cast<int>(tasks.at(i).type)); } } } @@ -135,15 +135,13 @@ void OutputParserTester::setDebugEnabled(bool debug) void OutputParserTester::stdOutput(const QString &line) { - if (!m_receivedStdOutChildLine.isEmpty()) - m_receivedStdOutChildLine.append(QChar('\n')); + QVERIFY(line.endsWith(QLatin1Char('\n'))); m_receivedStdOutChildLine.append(line); } void OutputParserTester::stdError(const QString &line) { - if (!m_receivedStdErrChildLine.isEmpty()) - m_receivedStdErrChildLine.append(QChar('\n')); + QVERIFY(line.endsWith(QLatin1Char('\n'))); m_receivedStdErrChildLine.append(line); } diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index e60aa89c1d5..5e6bbba1de1 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -224,6 +224,9 @@ private slots: void testGccOutputParsers_data(); void testGccOutputParsers(); + void testClangOutputParser_data(); + void testClangOutputParser(); + void testLinuxIccOutputParsers_data(); void testLinuxIccOutputParsers(); diff --git a/src/plugins/qt4projectmanager/qmakeparser.cpp b/src/plugins/qt4projectmanager/qmakeparser.cpp index 342c4e04f49..19d8e7332de 100644 --- a/src/plugins/qt4projectmanager/qmakeparser.cpp +++ b/src/plugins/qt4projectmanager/qmakeparser.cpp @@ -116,12 +116,12 @@ void Qt4ProjectManagerPlugin::testQmakeOutputParsers_data() QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<ProjectExplorer::Task>() << QString(); diff --git a/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp b/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp index 248d0f46470..c54786eec27 100644 --- a/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp @@ -210,12 +210,12 @@ void Qt4ProjectManagerPlugin::testAbldOutputParsers_data() QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<ProjectExplorer::Task>() << QString(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp b/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp index ebb89ba95a5..54b1e4ecfb6 100644 --- a/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp @@ -157,12 +157,12 @@ void Qt4ProjectManagerPlugin::testRvctOutputParser_data() QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<ProjectExplorer::Task>() << QString(); diff --git a/src/plugins/qt4projectmanager/qtparser.cpp b/src/plugins/qt4projectmanager/qtparser.cpp index a32e63ec67d..5af65d36cec 100644 --- a/src/plugins/qt4projectmanager/qtparser.cpp +++ b/src/plugins/qt4projectmanager/qtparser.cpp @@ -98,12 +98,12 @@ void Qt4ProjectManagerPlugin::testQtOutputParser_data() QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT - << QString::fromLatin1("Sometext") << QString() + << QString::fromLatin1("Sometext\n") << QString() << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR - << QString() << QString::fromLatin1("Sometext") + << QString() << QString::fromLatin1("Sometext\n") << QList<ProjectExplorer::Task>() << QString(); QTest::newRow("pass-through gcc infos") @@ -111,7 +111,7 @@ void Qt4ProjectManagerPlugin::testQtOutputParser_data() "../../scriptbug/main.cpp: At global scope:\n" "../../scriptbug/main.cpp: In instantiation of void bar(i) [with i = double]:\n" "../../scriptbug/main.cpp:8: instantiated from void foo(i) [with i = double]\n" - "../../scriptbug/main.cpp:22: instantiated from here\n") + "../../scriptbug/main.cpp:22: instantiated from here") << OutputParserTester::STDERR << QString() << QString::fromLatin1("/temp/test/untitled8/main.cpp: In function `int main(int, char**)':\n" -- GitLab