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 **************************************************************************/
30 #include "qmakeparser.h"
31 #include "qt4projectmanagerconstants.h"
33 #include <projectexplorer/taskwindow.h>
34 #include <projectexplorer/projectexplorerconstants.h>
35 #include <utils/qtcassert.h>
38 using namespace Qt4ProjectManager;
39 using namespace Qt4ProjectManager::Internal;
40 using ProjectExplorer::Task;
42 QMakeParser::QMakeParser()
44 setObjectName(QLatin1String("QMakeParser"));
46 m_error.setPattern("^(.+):(\\d+):\\s(.+)$");
47 m_error.setMinimal(true);
50 void QMakeParser::stdError(const QString &line)
52 QString lne(line.trimmed());
53 if (lne.startsWith(QLatin1String("Project ERROR:"))) {
54 const QString description = lne.mid(15);
55 emit addTask(Task(Task::Error,
57 QString() /* filename */,
59 ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
62 if (lne.startsWith(QLatin1String("Project WARNING:"))) {
63 const QString description = lne.mid(17);
64 emit addTask(Task(Task::Warning,
66 QString() /* filename */,
68 ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
71 if (m_error.indexIn(lne) > -1) {
72 emit addTask(Task(Task::Error,
73 m_error.cap(3) /* description */,
74 QDir::fromNativeSeparators(m_error.cap(1)) /* file */,
75 m_error.cap(2).toInt() /* line */,
76 ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
79 IOutputParser::stdError(line);
88 # include "qt4projectmanagerplugin.h"
90 # include "projectexplorer/outputparser_test.h"
92 using namespace Qt4ProjectManager::Internal;
93 using namespace ProjectExplorer;
95 void Qt4ProjectManagerPlugin::testQmakeOutputParsers_data()
97 QTest::addColumn<QString>("input");
98 QTest::addColumn<OutputParserTester::Channel>("inputChannel");
99 QTest::addColumn<QString>("childStdOutLines");
100 QTest::addColumn<QString>("childStdErrLines");
101 QTest::addColumn<QList<ProjectExplorer::Task> >("tasks");
102 QTest::addColumn<QString>("outputLines");
105 QTest::newRow("pass-through stdout")
106 << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT
107 << QString::fromLatin1("Sometext") << QString()
108 << QList<ProjectExplorer::Task>()
110 QTest::newRow("pass-through stderr")
111 << QString::fromLatin1("Sometext") << OutputParserTester::STDERR
112 << QString() << QString::fromLatin1("Sometext")
113 << QList<ProjectExplorer::Task>()
116 QTest::newRow("qMake error")
117 << QString::fromLatin1("Project ERROR: undefined file")
118 << OutputParserTester::STDERR
119 << QString() << QString()
120 << (QList<ProjectExplorer::Task>()
122 QLatin1String("undefined file"),
124 ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))
127 QTest::newRow("qMake Parse Error")
128 << QString::fromLatin1("e:\\project.pro:14: Parse Error ('sth odd')")
129 << OutputParserTester::STDERR
130 << QString() << QString()
131 << (QList<ProjectExplorer::Task>()
133 QLatin1String("Parse Error ('sth odd')"),
134 QDir::fromNativeSeparators(QLatin1String("e:\\project.pro")),
136 ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))
139 QTest::newRow("qMake warning")
140 << QString::fromLatin1("Project WARNING: bearer module might require ReadUserData capability")
141 << OutputParserTester::STDERR
142 << QString() << QString()
143 << (QList<ProjectExplorer::Task>()
144 << Task(Task::Warning,
145 QLatin1String("bearer module might require ReadUserData capability"),
147 ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))
151 void Qt4ProjectManagerPlugin::testQmakeOutputParsers()
153 OutputParserTester testbench;
154 testbench.appendOutputParser(new QMakeParser);
155 QFETCH(QString, input);
156 QFETCH(OutputParserTester::Channel, inputChannel);
157 QFETCH(QList<Task>, tasks);
158 QFETCH(QString, childStdOutLines);
159 QFETCH(QString, childStdErrLines);
160 QFETCH(QString, outputLines);
162 testbench.testParsing(input, inputChannel,
163 tasks, childStdOutLines, childStdErrLines,