File: testlinebuilderfunctions.h

package info (click to toggle)
kdevelop 4%3A5.6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 57,892 kB
  • sloc: cpp: 278,773; javascript: 3,558; python: 3,385; sh: 1,317; ansic: 689; xml: 273; php: 95; makefile: 40; lisp: 13; sed: 12
file content (197 lines) | stat: -rw-r--r-- 6,369 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
    This file is part of KDevelop
    Copyright (C) 2012  Morten Danielsen Volden mvolden2@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H
#define KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H

#include <QString>

namespace KDevelop
{

enum TestPathType {
    UnixFilePathNoSpaces,
    UnixFilePathWithSpaces,
    WindowsFilePathNoSpaces,
    WindowsFilePathWithSpaces
};

}

Q_DECLARE_METATYPE( KDevelop::TestPathType)

namespace KDevelop
{

// TODO: extend with other potential path patterns (network shares?)
static QString projectPath(TestPathType pathType = UnixFilePathNoSpaces)
{
    switch (pathType)
    {
        case WindowsFilePathNoSpaces:
            return QStringLiteral("C:/some/path/to/a/project");
        case WindowsFilePathWithSpaces:
            return QStringLiteral("C:/some/path with spaces/to/a/project");
        case UnixFilePathNoSpaces:
            return QStringLiteral("/some/path/to/a/project");
        case UnixFilePathWithSpaces:
            return QStringLiteral("/some/path with spaces/to/a/project");
    }
    Q_UNREACHABLE();
}

QString buildCppCheckErrorLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    /// Test CPP check output
    QString outputline(QStringLiteral("["));
    outputline.append(projectPath(pathType));
    outputline.append("main.cpp:26]: (error) Memory leak: str");
    return outputline;
}

QString buildKrazyErrorLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    /// Test krazy2 output
    QString outputline(QStringLiteral("\t"));
    outputline.append(projectPath(pathType));
    outputline.append("main.cpp: line#22 (1)");
    return outputline;
}

QString buildKrazyErrorLine2(TestPathType pathType = UnixFilePathNoSpaces)
{
    /// Test krazy2 output
    QString outputline(QStringLiteral("\t"));
    outputline.append(projectPath(pathType));
    outputline.append("main.cpp: missing tags: email address line#2  (1)");
    return outputline;
}

QString buildKrazyErrorLine3(TestPathType pathType = UnixFilePathNoSpaces)
{
    /// Test krazy2 output
    QString outputline(QStringLiteral("\t"));
    outputline.append(projectPath(pathType));
    outputline.append("main.cpp: non-const ref iterator line#451 (1)");
    return outputline;
}

QString buildKrazyErrorLineNoLineInfo(TestPathType pathType = UnixFilePathNoSpaces)
{
    /// Test krazy2 output
    QString outputline(QStringLiteral("\t"));
    outputline.append(projectPath(pathType));
    outputline.append("main.cpp: missing license");
    return outputline;
}

QString buildCompilerLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    /// Test with compiler output
    QString outputline;
    outputline.append(projectPath(pathType));
    outputline.append(">make");
    return outputline;
}

QString buildCompilerErrorLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    QString outputline;
    outputline.append(projectPath(pathType));
    outputline.append("main.cpp:5:5: error: ‘RingBuffer’ was not declared in this scope");
    return outputline;
}

QString buildCompilerInformationLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    QString outputline;
    outputline.append(projectPath(pathType));
    outputline.append("main.cpp:6:14: instantiated from here");
    return outputline;
}

QString buildInfileIncludedFromFirstLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    QString outputline(QStringLiteral("In file included from "));
    outputline.append(projectPath(pathType));
    outputline.append("PriorityFactory.h:52:0,");
    return outputline;
}

QString buildInfileIncludedFromSecondLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    QString outputline(QStringLiteral("    from "));
    outputline.append(projectPath(pathType));
    outputline.append("PatchBasedInpainting.hxx:29,");
    return outputline;
}

QString buildCompilerActionLine()
{
    return QStringLiteral("linking testCustombuild (g++)");
}

QString buildCmakeConfigureMultiLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    QString outputline;
    outputline.append(projectPath(pathType));
    outputline.append("CMakeLists.txt:10:");
    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)
{
    return projectPath(pathType) + QLatin1String("Buffer.cpp:66: undefined reference to `Buffer::does_not_exist()'");
}

QString buildPythonErrorLine(TestPathType pathType = UnixFilePathNoSpaces)
{
    QString outputline(QStringLiteral("File \""));
    outputline.append(projectPath(pathType));
    outputline.append("pythonExample.py\", line 10");
    return outputline;
}

QString buildCppCheckInformationLine()
{
    return QStringLiteral("(information) Cppcheck cannot find all the include files. Cpppcheck can check the code without the include\
    files found. But the results will probably be more accurate if all the include files are found. Please check your project's \
    include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config.");
}


}

#endif