1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
31 #include "qt4projectmanagerconstants.h"
33 #include <projectexplorer/taskwindow.h>
34 #include <projectexplorer/projectexplorerconstants.h>
35 #include <utils/qtcassert.h>
37 using namespace Qt4ProjectManager;
38 using namespace Qt4ProjectManager::Internal;
39 using ProjectExplorer::Task;
42 // opt. drive letter + filename: (2 brackets)
43 const char * const FILE_PATTERN = "^(([A-Za-z]:)?[^:]+\\.[^:]+):";
48 m_mocRegExp.setPattern(QString::fromLatin1(FILE_PATTERN) + "(\\d+):\\s(Warning|Error):\\s(.+)$");
49 m_mocRegExp.setMinimal(true);
52 void QtParser::stdError(const QString &line)
54 QString lne(line.trimmed());
55 if (m_mocRegExp.indexIn(lne) > -1) {
57 int lineno = m_mocRegExp.cap(3).toInt(&ok);
60 Task task(Task::Error,
61 m_mocRegExp.cap(5).trimmed(),
62 m_mocRegExp.cap(1) /* filename */,
64 ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
65 if (m_mocRegExp.cap(4) == QLatin1String("Warning"))
66 task.type = Task::Warning;
70 IOutputParser::stdError(line);
78 # include "qt4projectmanagerplugin.h"
79 # include <projectexplorer/projectexplorerconstants.h>
80 # include <projectexplorer/metatypedeclarations.h>
81 # include <projectexplorer/outputparser_test.h>
83 using namespace ProjectExplorer;
85 void Qt4ProjectManagerPlugin::testQtOutputParser_data()
87 QTest::addColumn<QString>("input");
88 QTest::addColumn<OutputParserTester::Channel>("inputChannel");
89 QTest::addColumn<QString>("childStdOutLines");
90 QTest::addColumn<QString>("childStdErrLines");
91 QTest::addColumn<QList<ProjectExplorer::Task> >("tasks");
92 QTest::addColumn<QString>("outputLines");
95 QTest::newRow("pass-through stdout")
96 << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT
97 << QString::fromLatin1("Sometext") << QString()
98 << QList<ProjectExplorer::Task>()
100 QTest::newRow("pass-through stderr")
101 << QString::fromLatin1("Sometext") << OutputParserTester::STDERR
102 << QString() << QString::fromLatin1("Sometext")
103 << QList<ProjectExplorer::Task>()
106 QTest::newRow("moc warning")
107 << QString::fromLatin1("..\\untitled\\errorfile.h:0: Warning: No relevant classes found. No output generated.")
108 << OutputParserTester::STDERR
109 << QString() << QString()
110 << (QList<ProjectExplorer::Task>() << Task(Task::Warning,
111 QLatin1String("No relevant classes found. No output generated."),
112 QLatin1String("..\\untitled\\errorfile.h"), 0,
113 ProjectExplorer::Constants::TASK_CATEGORY_COMPILE))
117 void Qt4ProjectManagerPlugin::testQtOutputParser()
119 OutputParserTester testbench;
120 testbench.appendOutputParser(new QtParser);
121 QFETCH(QString, input);
122 QFETCH(OutputParserTester::Channel, inputChannel);
123 QFETCH(QList<Task>, tasks);
124 QFETCH(QString, childStdOutLines);
125 QFETCH(QString, childStdErrLines);
126 QFETCH(QString, outputLines);
128 testbench.testParsing(input, inputChannel, tasks, childStdOutLines, childStdErrLines, outputLines);