Changeset View
Changeset View
Standalone View
Standalone View
outputview/tests/testlinebuilderfunctions.h
Show All 14 Lines | 1 | /* | |||
---|---|---|---|---|---|
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | #ifndef KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H | 18 | #ifndef KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H | ||
19 | #define KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H | 19 | #define KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H | ||
20 | 20 | | |||
21 | #include <QUrl> | 21 | #include <QUrl> | ||
22 | #include <QString> | 22 | #include <QString> | ||
23 | #include <QFileInfo> | | |||
24 | 23 | | |||
25 | #define PROJECTS_SOURCE_DIR | 24 | namespace KDevelop | ||
25 | { | ||||
26 | | ||||
27 | enum TestPathType { | ||||
28 | UnixFilePathNoSpaces, | ||||
29 | UnixFilePathWithSpaces | ||||
30 | }; | ||||
31 | | ||||
32 | } | ||||
33 | | ||||
34 | Q_DECLARE_METATYPE( KDevelop::TestPathType) | ||||
26 | 35 | | |||
27 | namespace KDevelop | 36 | namespace KDevelop | ||
28 | { | 37 | { | ||
29 | 38 | | |||
30 | static QString projectPath() | 39 | // TODO: extend with windows path and other potential path patterns (network shares?) | ||
40 | static QString projectPath(TestPathType pathType = UnixFilePathNoSpaces) | ||||
31 | { | 41 | { | ||
32 | /// Use existing directory with one file | 42 | return | ||
33 | return QFileInfo(QStringLiteral(__FILE__)).absolutePath() + QLatin1String("/onefileproject"); | 43 | (pathType == UnixFilePathNoSpaces) ? QStringLiteral("/some/path/to/a/project") : | ||
44 | /* else, UnixFilePathWithSpaces) */ QStringLiteral("/some/path with spaces/to/a/project"); | ||||
34 | } | 45 | } | ||
35 | 46 | | |||
36 | QString buildCppCheckErrorLine() | 47 | QString buildCppCheckErrorLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
37 | { | 48 | { | ||
38 | /// Test CPP check output | 49 | /// Test CPP check output | ||
39 | QString outputline(QStringLiteral("[")); | 50 | QString outputline(QStringLiteral("[")); | ||
40 | outputline.append(projectPath()); | 51 | outputline.append(projectPath(pathType)); | ||
41 | outputline.append("main.cpp:26]: (error) Memory leak: str"); | 52 | outputline.append("main.cpp:26]: (error) Memory leak: str"); | ||
42 | return outputline; | 53 | return outputline; | ||
43 | } | 54 | } | ||
44 | 55 | | |||
45 | QString buildKrazyErrorLine() | 56 | QString buildKrazyErrorLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
46 | { | 57 | { | ||
47 | /// Test krazy2 output | 58 | /// Test krazy2 output | ||
48 | QString outputline(QStringLiteral("\t")); | 59 | QString outputline(QStringLiteral("\t")); | ||
49 | outputline.append(projectPath()); | 60 | outputline.append(projectPath(pathType)); | ||
50 | outputline.append("main.cpp: line#22 (1)"); | 61 | outputline.append("main.cpp: line#22 (1)"); | ||
51 | return outputline; | 62 | return outputline; | ||
52 | } | 63 | } | ||
53 | 64 | | |||
54 | QString buildKrazyErrorLine2() | 65 | QString buildKrazyErrorLine2(TestPathType pathType = UnixFilePathNoSpaces) | ||
55 | { | 66 | { | ||
56 | /// Test krazy2 output | 67 | /// Test krazy2 output | ||
57 | QString outputline(QStringLiteral("\t")); | 68 | QString outputline(QStringLiteral("\t")); | ||
58 | outputline.append(projectPath()); | 69 | outputline.append(projectPath(pathType)); | ||
59 | outputline.append("main.cpp: missing tags: email address line#2 (1)"); | 70 | outputline.append("main.cpp: missing tags: email address line#2 (1)"); | ||
60 | return outputline; | 71 | return outputline; | ||
61 | } | 72 | } | ||
62 | 73 | | |||
63 | QString buildKrazyErrorLine3() | 74 | QString buildKrazyErrorLine3(TestPathType pathType = UnixFilePathNoSpaces) | ||
64 | { | 75 | { | ||
65 | /// Test krazy2 output | 76 | /// Test krazy2 output | ||
66 | QString outputline(QStringLiteral("\t")); | 77 | QString outputline(QStringLiteral("\t")); | ||
67 | outputline.append(projectPath()); | 78 | outputline.append(projectPath(pathType)); | ||
68 | outputline.append("main.cpp: non-const ref iterator line#451 (1)"); | 79 | outputline.append("main.cpp: non-const ref iterator line#451 (1)"); | ||
69 | return outputline; | 80 | return outputline; | ||
70 | } | 81 | } | ||
71 | 82 | | |||
72 | QString buildKrazyErrorLineNoLineInfo() | 83 | QString buildKrazyErrorLineNoLineInfo(TestPathType pathType = UnixFilePathNoSpaces) | ||
73 | { | 84 | { | ||
74 | /// Test krazy2 output | 85 | /// Test krazy2 output | ||
75 | QString outputline(QStringLiteral("\t")); | 86 | QString outputline(QStringLiteral("\t")); | ||
76 | outputline.append(projectPath()); | 87 | outputline.append(projectPath(pathType)); | ||
77 | outputline.append("main.cpp: missing license"); | 88 | outputline.append("main.cpp: missing license"); | ||
78 | return outputline; | 89 | return outputline; | ||
79 | } | 90 | } | ||
80 | 91 | | |||
81 | QString buildCompilerLine() | 92 | QString buildCompilerLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
82 | { | 93 | { | ||
83 | /// Test with compiler output | 94 | /// Test with compiler output | ||
84 | QString outputline; | 95 | QString outputline; | ||
85 | outputline.append(projectPath()); | 96 | outputline.append(projectPath(pathType)); | ||
86 | outputline.append(">make"); | 97 | outputline.append(">make"); | ||
87 | return outputline; | 98 | return outputline; | ||
88 | } | 99 | } | ||
89 | 100 | | |||
90 | QString buildCompilerErrorLine() | 101 | QString buildCompilerErrorLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
91 | { | 102 | { | ||
92 | QString outputline; | 103 | QString outputline; | ||
93 | outputline.append(projectPath()); | 104 | outputline.append(projectPath(pathType)); | ||
94 | outputline.append("main.cpp:5:5: error: ‘RingBuffer’ was not declared in this scope"); | 105 | outputline.append("main.cpp:5:5: error: ‘RingBuffer’ was not declared in this scope"); | ||
95 | return outputline; | 106 | return outputline; | ||
96 | } | 107 | } | ||
97 | 108 | | |||
98 | QString buildCompilerInformationLine() | 109 | QString buildCompilerInformationLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
99 | { | 110 | { | ||
100 | QString outputline; | 111 | QString outputline; | ||
101 | outputline.append(projectPath()); | 112 | outputline.append(projectPath(pathType)); | ||
102 | outputline.append("main.cpp:6:14: instantiated from here"); | 113 | outputline.append("main.cpp:6:14: instantiated from here"); | ||
103 | return outputline; | 114 | return outputline; | ||
104 | } | 115 | } | ||
105 | 116 | | |||
106 | QString buildInfileIncludedFromFirstLine() | 117 | QString buildInfileIncludedFromFirstLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
107 | { | 118 | { | ||
108 | QString outputline(QStringLiteral("In file included from ")); | 119 | QString outputline(QStringLiteral("In file included from ")); | ||
109 | outputline.append(projectPath()); | 120 | outputline.append(projectPath(pathType)); | ||
110 | outputline.append("PriorityFactory.h:52:0,"); | 121 | outputline.append("PriorityFactory.h:52:0,"); | ||
111 | return outputline; | 122 | return outputline; | ||
112 | } | 123 | } | ||
113 | 124 | | |||
114 | QString buildInfileIncludedFromSecondLine() | 125 | QString buildInfileIncludedFromSecondLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
115 | { | 126 | { | ||
116 | QString outputline(QStringLiteral(" from ")); | 127 | QString outputline(QStringLiteral(" from ")); | ||
117 | outputline.append(projectPath()); | 128 | outputline.append(projectPath(pathType)); | ||
118 | outputline.append("PatchBasedInpainting.hxx:29,"); | 129 | outputline.append("PatchBasedInpainting.hxx:29,"); | ||
119 | return outputline; | 130 | return outputline; | ||
120 | } | 131 | } | ||
121 | 132 | | |||
122 | QString buildCompilerActionLine() | 133 | QString buildCompilerActionLine() | ||
123 | { | 134 | { | ||
124 | return QStringLiteral("linking testCustombuild (g++)"); | 135 | return QStringLiteral("linking testCustombuild (g++)"); | ||
125 | } | 136 | } | ||
126 | 137 | | |||
127 | QString buildCmakeConfigureMultiLine() | 138 | QString buildCmakeConfigureMultiLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
128 | { | 139 | { | ||
129 | QString outputline; | 140 | QString outputline; | ||
130 | outputline.append(projectPath()); | 141 | outputline.append(projectPath(pathType)); | ||
131 | outputline.append("CMakeLists.txt:10:"); | 142 | outputline.append("CMakeLists.txt:10:"); | ||
132 | return outputline; | 143 | return outputline; | ||
133 | } | 144 | } | ||
134 | 145 | | |||
135 | 146 | | |||
136 | QString buildLinkerErrorLine() | 147 | QString buildLinkerErrorLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
137 | { | 148 | { | ||
138 | return QStringLiteral("/path/to/file/Buffer.cpp:66: undefined reference to `Buffer::does_not_exist()'"); | 149 | return projectPath(pathType) + QLatin1String("Buffer.cpp:66: undefined reference to `Buffer::does_not_exist()'"); | ||
139 | } | 150 | } | ||
140 | 151 | | |||
141 | QString buildPythonErrorLine() | 152 | QString buildPythonErrorLine(TestPathType pathType = UnixFilePathNoSpaces) | ||
142 | { | 153 | { | ||
143 | QString outputline(QStringLiteral("File \"")); | 154 | QString outputline(QStringLiteral("File \"")); | ||
144 | outputline.append(projectPath()); | 155 | outputline.append(projectPath(pathType)); | ||
145 | outputline.append("pythonExample.py\", line 10"); | 156 | outputline.append("pythonExample.py\", line 10"); | ||
146 | return outputline; | 157 | return outputline; | ||
147 | } | 158 | } | ||
148 | 159 | | |||
149 | QString buildCppCheckInformationLine() | 160 | QString buildCppCheckInformationLine() | ||
150 | { | 161 | { | ||
151 | return QStringLiteral("(information) Cppcheck cannot find all the include files. Cpppcheck can check the code without the include\ | 162 | return QStringLiteral("(information) Cppcheck cannot find all the include files. Cpppcheck can check the code without the include\ | ||
152 | files found. But the results will probably be more accurate if all the include files are found. Please check your project's \ | 163 | files found. But the results will probably be more accurate if all the include files are found. Please check your project's \ | ||
153 | include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config."); | 164 | include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config."); | ||
154 | } | 165 | } | ||
155 | 166 | | |||
156 | 167 | | |||
157 | } | 168 | } | ||
158 | 169 | | |||
159 | #endif | 170 | #endif |