File indexing completed on 2024-05-12 04:38:09
0001 /* 0002 SPDX-FileCopyrightText: 2012 Morten Danielsen Volden <mvolden2@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H 0008 #define KDEVPLATFORM_TESTLINEBUILDERFUNCTIONS_H 0009 0010 #include <QString> 0011 0012 namespace KDevelop 0013 { 0014 0015 enum TestPathType { 0016 UnixFilePathNoSpaces, 0017 UnixFilePathWithSpaces, 0018 WindowsFilePathNoSpaces, 0019 WindowsFilePathWithSpaces 0020 }; 0021 0022 } 0023 0024 Q_DECLARE_METATYPE( KDevelop::TestPathType) 0025 0026 namespace KDevelop 0027 { 0028 0029 // TODO: extend with other potential path patterns (network shares?) 0030 static QString projectPath(TestPathType pathType = UnixFilePathNoSpaces) 0031 { 0032 switch (pathType) 0033 { 0034 case WindowsFilePathNoSpaces: 0035 return QStringLiteral("C:/some/path/to/a/project"); 0036 case WindowsFilePathWithSpaces: 0037 return QStringLiteral("C:/some/path with spaces/to/a/project"); 0038 case UnixFilePathNoSpaces: 0039 return QStringLiteral("/some/path/to/a/project"); 0040 case UnixFilePathWithSpaces: 0041 return QStringLiteral("/some/path with spaces/to/a/project"); 0042 } 0043 Q_UNREACHABLE(); 0044 } 0045 0046 QString buildCppCheckErrorLine(TestPathType pathType = UnixFilePathNoSpaces) 0047 { 0048 /// Test CPP check output 0049 QString outputline(QStringLiteral("[")); 0050 outputline.append(projectPath(pathType)); 0051 outputline.append("main.cpp:26]: (error) Memory leak: str"); 0052 return outputline; 0053 } 0054 0055 QString buildKrazyErrorLine(TestPathType pathType = UnixFilePathNoSpaces) 0056 { 0057 /// Test krazy2 output 0058 QString outputline(QStringLiteral("\t")); 0059 outputline.append(projectPath(pathType)); 0060 outputline.append("main.cpp: line#22 (1)"); 0061 return outputline; 0062 } 0063 0064 QString buildKrazyErrorLine2(TestPathType pathType = UnixFilePathNoSpaces) 0065 { 0066 /// Test krazy2 output 0067 QString outputline(QStringLiteral("\t")); 0068 outputline.append(projectPath(pathType)); 0069 outputline.append("main.cpp: missing tags: email address line#2 (1)"); 0070 return outputline; 0071 } 0072 0073 QString buildKrazyErrorLine3(TestPathType pathType = UnixFilePathNoSpaces) 0074 { 0075 /// Test krazy2 output 0076 QString outputline(QStringLiteral("\t")); 0077 outputline.append(projectPath(pathType)); 0078 outputline.append("main.cpp: non-const ref iterator line#451 (1)"); 0079 return outputline; 0080 } 0081 0082 QString buildKrazyErrorLineNoLineInfo(TestPathType pathType = UnixFilePathNoSpaces) 0083 { 0084 /// Test krazy2 output 0085 QString outputline(QStringLiteral("\t")); 0086 outputline.append(projectPath(pathType)); 0087 outputline.append("main.cpp: missing license"); 0088 return outputline; 0089 } 0090 0091 QString buildCompilerLine(TestPathType pathType = UnixFilePathNoSpaces) 0092 { 0093 /// Test with compiler output 0094 QString outputline; 0095 outputline.append(projectPath(pathType)); 0096 outputline.append(">make"); 0097 return outputline; 0098 } 0099 0100 QString buildCompilerErrorLine(TestPathType pathType = UnixFilePathNoSpaces) 0101 { 0102 QString outputline; 0103 outputline.append(projectPath(pathType)); 0104 outputline.append("main.cpp:5:5: error: ‘RingBuffer’ was not declared in this scope"); 0105 return outputline; 0106 } 0107 0108 QString buildCompilerInformationLine(TestPathType pathType = UnixFilePathNoSpaces) 0109 { 0110 QString outputline; 0111 outputline.append(projectPath(pathType)); 0112 outputline.append("main.cpp:6:14: instantiated from here"); 0113 return outputline; 0114 } 0115 0116 QString buildInfileIncludedFromFirstLine(TestPathType pathType = UnixFilePathNoSpaces) 0117 { 0118 QString outputline(QStringLiteral("In file included from ")); 0119 outputline.append(projectPath(pathType)); 0120 outputline.append("PriorityFactory.h:52:0,"); 0121 return outputline; 0122 } 0123 0124 QString buildInfileIncludedFromSecondLine(TestPathType pathType = UnixFilePathNoSpaces) 0125 { 0126 QString outputline(QStringLiteral(" from ")); 0127 outputline.append(projectPath(pathType)); 0128 outputline.append("PatchBasedInpainting.hxx:29,"); 0129 return outputline; 0130 } 0131 0132 QString buildCompilerActionLine() 0133 { 0134 return QStringLiteral("linking testCustombuild (g++)"); 0135 } 0136 0137 QString buildCmakeConfigureMultiLine(TestPathType pathType = UnixFilePathNoSpaces) 0138 { 0139 QString outputline; 0140 outputline.append(projectPath(pathType)); 0141 outputline.append("CMakeLists.txt:10:"); 0142 return outputline; 0143 } 0144 0145 QString buildAutoMocLine(TestPathType pathType = UnixFilePathNoSpaces, bool useAutoMoc = true) 0146 { 0147 QString outputline; 0148 useAutoMoc ? outputline.append("AUTOMOC: error: ") : outputline.append("AUTOGEN: error: "); 0149 outputline.append(projectPath(pathType)); 0150 outputline.append("bar.cpp The file includes the moc file \"moc_bar1.cpp\""); 0151 return outputline; 0152 } 0153 0154 QString buildOldAutoMocLine(TestPathType pathType = UnixFilePathNoSpaces) 0155 { 0156 QString outputline; 0157 outputline.append("automoc4: The file \""); 0158 outputline.append(projectPath(pathType)); 0159 outputline.append("bar.cpp\" includes the moc file \"bar1.moc\""); 0160 return outputline; 0161 } 0162 0163 QString buildLinkerErrorLine(TestPathType pathType = UnixFilePathNoSpaces) 0164 { 0165 return projectPath(pathType) + QLatin1String("Buffer.cpp:66: undefined reference to `Buffer::does_not_exist()'"); 0166 } 0167 0168 QString buildPythonErrorLine(TestPathType pathType = UnixFilePathNoSpaces) 0169 { 0170 QString outputline(QStringLiteral("File \"")); 0171 outputline.append(projectPath(pathType)); 0172 outputline.append("pythonExample.py\", line 10"); 0173 return outputline; 0174 } 0175 0176 QString buildCppCheckInformationLine() 0177 { 0178 return QStringLiteral("(information) Cppcheck cannot find all the include files. Cpppcheck can check the code without the include\ 0179 files found. But the results will probably be more accurate if all the include files are found. Please check your project's \ 0180 include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config."); 0181 } 0182 0183 0184 } 0185 0186 #endif