1
/****************************************************************************
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of Qt Creator.
8
** Commercial License Usage
9
** Licensees holding valid commercial Qt licenses may use this file in
10
** accordance with the commercial license agreement provided with the
11
** Software or, alternatively, in accordance with the terms contained in
12
** a written agreement between you and Digia. For licensing terms and
13
** conditions see http://qt.digia.com/licensing. For further information
14
** use the contact form at http://qt.digia.com/contact-us.
16
** GNU Lesser General Public License Usage
17
** Alternatively, this file may be used under the terms of the GNU Lesser
18
** General Public License version 2.1 as published by the Free Software
19
** Foundation and appearing in the file LICENSE.LGPL included in the
20
** packaging of this file. Please review the following information to
21
** ensure the GNU Lesser General Public License version 2.1 requirements
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
** In addition, as a special exception, Digia gives you certain additional
25
** rights. These rights are described in the Digia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
****************************************************************************/
30
#include "qmakeparser.h"
32
#include <projectexplorer/task.h>
33
#include <projectexplorer/projectexplorerconstants.h>
35
using namespace QmakeProjectManager;
36
using namespace QmakeProjectManager::Internal;
37
using ProjectExplorer::Task;
39
QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+):(\\d+):\\s(.+)$"))
41
setObjectName(QLatin1String("QMakeParser"));
42
m_error.setMinimal(true);
45
void QMakeParser::stdError(const QString &line)
47
QString lne = rightTrimmed(line);
48
if (lne.startsWith(QLatin1String("Project ERROR:"))) {
49
const QString description = lne.mid(15);
50
emit addTask(Task(Task::Error,
52
Utils::FileName() /* filename */,
54
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
57
if (lne.startsWith(QLatin1String("Project WARNING:"))) {
58
const QString description = lne.mid(17);
59
emit addTask(Task(Task::Warning,
61
Utils::FileName() /* filename */,
63
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
66
if (m_error.indexIn(lne) > -1) {
67
QString fileName = m_error.cap(1);
68
Task::TaskType type = Task::Error;
69
if (fileName.startsWith(QLatin1String("WARNING: "))) {
71
fileName = fileName.mid(9);
72
} else if (fileName.startsWith(QLatin1String("ERROR: "))) {
73
fileName = fileName.mid(7);
75
emit addTask(Task(type,
76
m_error.cap(3) /* description */,
77
Utils::FileName::fromUserInput(fileName),
78
m_error.cap(2).toInt() /* line */,
79
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
82
IOutputParser::stdError(line);
91
# include "qmakeprojectmanagerplugin.h"
93
# include "projectexplorer/outputparser_test.h"
95
using namespace QmakeProjectManager::Internal;
96
using namespace ProjectExplorer;
98
void QmakeProjectManagerPlugin::testQmakeOutputParsers_data()
100
const Core::Id categoryBuildSystem = Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
101
QTest::addColumn<QString>("input");
102
QTest::addColumn<OutputParserTester::Channel>("inputChannel");
103
QTest::addColumn<QString>("childStdOutLines");
104
QTest::addColumn<QString>("childStdErrLines");
105
QTest::addColumn<QList<ProjectExplorer::Task> >("tasks");
106
QTest::addColumn<QString>("outputLines");
109
QTest::newRow("pass-through stdout")
110
<< QString::fromLatin1("Sometext") << OutputParserTester::STDOUT
111
<< QString::fromLatin1("Sometext\n") << QString()
112
<< QList<ProjectExplorer::Task>()
114
QTest::newRow("pass-through stderr")
115
<< QString::fromLatin1("Sometext") << OutputParserTester::STDERR
116
<< QString() << QString::fromLatin1("Sometext\n")
117
<< QList<ProjectExplorer::Task>()
120
QTest::newRow("qMake error")
121
<< QString::fromLatin1("Project ERROR: undefined file")
122
<< OutputParserTester::STDERR
123
<< QString() << QString()
124
<< (QList<ProjectExplorer::Task>()
126
QLatin1String("undefined file"),
127
Utils::FileName(), -1,
128
categoryBuildSystem))
131
QTest::newRow("qMake Parse Error")
132
<< QString::fromLatin1("e:\\project.pro:14: Parse Error ('sth odd')")
133
<< OutputParserTester::STDERR
134
<< QString() << QString()
135
<< (QList<ProjectExplorer::Task>()
137
QLatin1String("Parse Error ('sth odd')"),
138
Utils::FileName::fromUserInput(QLatin1String("e:\\project.pro")),
140
categoryBuildSystem))
143
QTest::newRow("qMake warning")
144
<< QString::fromLatin1("Project WARNING: bearer module might require ReadUserData capability")
145
<< OutputParserTester::STDERR
146
<< QString() << QString()
147
<< (QList<ProjectExplorer::Task>()
148
<< Task(Task::Warning,
149
QLatin1String("bearer module might require ReadUserData capability"),
150
Utils::FileName(), -1,
151
categoryBuildSystem))
154
QTest::newRow("qMake warning with location")
155
<< QString::fromLatin1("WARNING: e:\\QtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl:1: Unescaped backslashes are deprecated.")
156
<< OutputParserTester::STDERR
157
<< QString() << QString()
158
<< (QList<ProjectExplorer::Task>()
159
<< Task(Task::Warning,
160
QLatin1String("Unescaped backslashes are deprecated."),
161
Utils::FileName::fromUserInput(QLatin1String("e:\\QtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl")), 1,
162
categoryBuildSystem))
166
void QmakeProjectManagerPlugin::testQmakeOutputParsers()
168
OutputParserTester testbench;
169
testbench.appendOutputParser(new QMakeParser);
170
QFETCH(QString, input);
171
QFETCH(OutputParserTester::Channel, inputChannel);
172
QFETCH(QList<Task>, tasks);
173
QFETCH(QString, childStdOutLines);
174
QFETCH(QString, childStdErrLines);
175
QFETCH(QString, outputLines);
177
testbench.testParsing(input, inputChannel,
178
tasks, childStdOutLines, childStdErrLines,